How to use project_root method in dbt-osmosis

Best Python code snippet using dbt-osmosis_python

tasks.py

Source:tasks.py Github

copy

Full Screen

1import pathlib2import subprocess3from invoke import task4import DocTest5project_root = pathlib.Path(__file__).parent.resolve().as_posix()6@task7def tests(context):8 cmd = [9 "coverage",10 "run",11 "-m",12 "pytest",13 f"{project_root}/utest",14 ]15 subprocess.run(" ".join(cmd), shell=True)16 cmd = [17 "coverage",18 "run",19 "-m",20 "robot",21 f"--variable=root:{project_root}",22 f"--outputdir={project_root}/reports",23 f"--loglevel=TRACE:DEBUG",24 f"{project_root}/atest",25 ]26 subprocess.run(" ".join(cmd), shell=True)27 subprocess.run("coverage combine", shell=True)28 subprocess.run("coverage report", shell=True)29 subprocess.run("coverage html", shell=True)30@task31def lint(context):32 subprocess.run(f"mypy {project_root}", shell=True)33 subprocess.run(f"pylint {project_root}/src/OpenApiDriver", shell=True)34@task35def format_code(context):36 subprocess.run(f"python -m black {project_root}", shell=True)37 subprocess.run(f"python -m isort {project_root}", shell=True)38 subprocess.run(f"robotidy {project_root}", shell=True)39@task40def libdoc(context):41 source = f"{project_root}/DocTest/VisualTest.py"42 target = f"{project_root}/docs/VisualTest.html"43 cmd = [44 "python",45 "-m",46 "robot.libdoc",47 source,48 target,49 ]50 subprocess.run(" ".join(cmd), shell=True)51 source = f"{project_root}/DocTest/PdfTest.py"52 target = f"{project_root}/docs/PdfTest.html"53 cmd = [54 "python",55 "-m",56 "robot.libdoc",57 source,58 target,59 ]60 subprocess.run(" ".join(cmd), shell=True)61 source = f"{project_root}/DocTest/PrintJobTests.py"62 target = f"{project_root}/docs/PrintJobTest.html"63 cmd = [64 "python",65 "-m",66 "robot.libdoc",67 source,68 target,69 ]70 subprocess.run(" ".join(cmd), shell=True)71@task72def libspec(context):73 source = f"{project_root}/DocTest/VisualTest.py"74 target = f"{project_root}/docs/VisualTest.libspec"75 cmd = [76 "python",77 "-m",78 "robot.libdoc",79 source,80 target,81 ]82 subprocess.run(" ".join(cmd), shell=True)83 source = f"{project_root}/DocTest/PdfTest.py"84 target = f"{project_root}/docs/PdfTest.libspec"85 cmd = [86 "python",87 "-m",88 "robot.libdoc",89 source,90 target,91 ]92 subprocess.run(" ".join(cmd), shell=True)93 source = f"{project_root}/DocTest/PrintJobTests.py"94 target = f"{project_root}/docs/PrintJobTest.libspec"95 cmd = [96 "python",97 "-m",98 "robot.libdoc",99 source,100 target,101 ]102 subprocess.run(" ".join(cmd), shell=True)103@task104def readme(context):105 with open(f"{project_root}/README.md", "w", encoding="utf-8") as readme:106 doc_string = DocTest.__doc__107 print(doc_string)108 #readme.write(str(doc_string).replace("\\", "\\\\").replace("\\\\*", "\\*"))109@task(tests, libdoc, libspec)110def build(context):111 print("Creating Build")112 # subprocess.run("poetry build", shell=True)113# @task(post=[build])114# def bump_version(context, rule):...

Full Screen

Full Screen

test_clean_pyc.py

Source:test_clean_pyc.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import fnmatch3import os4import shutil5import six6from django.core.management import call_command7from django.test import TestCase8class CleanPycTests(TestCase):9 def setUp(self):10 self.project_root = os.path.join('tests', 'testapp')11 self._settings = os.environ.get('DJANGO_SETTINGS_MODULE')12 os.environ['DJANGO_SETTINGS_MODULE'] = 'django_extensions.settings'13 def tearDown(self):14 if self._settings:15 os.environ['DJANGO_SETTINGS_MODULE'] = self._settings16 def _find_pyc(self, path):17 pyc_glob = []18 for root, dirnames, filenames in os.walk(path):19 for filename in fnmatch.filter(filenames, '*.pyc'):20 pyc_glob.append(os.path.join(root, filename))21 return pyc_glob22 def test_removes_pyc_files(self):23 with self.settings(BASE_DIR=self.project_root):24 call_command('compile_pyc')25 pyc_glob = self._find_pyc(self.project_root)26 self.assertTrue(len(pyc_glob) > 0)27 with self.settings(BASE_DIR=self.project_root):28 call_command('clean_pyc')29 pyc_glob = self._find_pyc(self.project_root)30 self.assertEqual(len(pyc_glob), 0)31 def test_takes_path(self):32 out = six.StringIO()33 project_root = os.path.join('tests', 'testapp')34 call_command('compile_pyc', path=project_root)35 pyc_glob = self._find_pyc(project_root)36 self.assertTrue(len(pyc_glob) > 0)37 call_command('clean_pyc', verbosity=2, path=project_root, stdout=out)38 output = out.getvalue().splitlines()39 self.assertEqual(sorted(pyc_glob), sorted(output))40 def test_removes_pyo_files(self):41 out = six.StringIO()42 project_root = os.path.join('tests', 'testapp')43 call_command('compile_pyc', path=project_root)44 pyc_glob = self._find_pyc(project_root)45 self.assertTrue(len(pyc_glob) > 0)46 # Create some fake .pyo files since we can't force them to be created.47 pyo_glob = []48 for fn in pyc_glob:49 pyo = '%s.pyo' % os.path.splitext(fn)[0]50 shutil.copyfile(fn, pyo)51 pyo_glob.append(pyo)52 call_command('clean_pyc', verbosity=2, path=project_root, optimize=True, stdout=out)53 output = out.getvalue().splitlines()...

Full Screen

Full Screen

test_compile_pyc.py

Source:test_compile_pyc.py Github

copy

Full Screen

1# -*- coding: utf-8 -*-2import fnmatch3import os4import six5from django.core.management import call_command6from django.test import TestCase7class CompilePycTests(TestCase):8 def setUp(self):9 self.project_root = os.path.join('tests', 'testapp')10 self._settings = os.environ.get('DJANGO_SETTINGS_MODULE')11 os.environ['DJANGO_SETTINGS_MODULE'] = 'django_extensions.settings'12 def tearDown(self):13 if self._settings:14 os.environ['DJANGO_SETTINGS_MODULE'] = self._settings15 def _find_pyc(self, path, mask='*.pyc'):16 pyc_glob = []17 for root, dirs, filenames in os.walk(path):18 for filename in fnmatch.filter(filenames, mask):19 pyc_glob.append(os.path.join(root, filename))20 return pyc_glob21 def test_compiles_pyc_files(self):22 with self.settings(BASE_DIR=self.project_root):23 call_command('clean_pyc')24 pyc_glob = self._find_pyc(self.project_root)25 self.assertEqual(len(pyc_glob), 0)26 with self.settings(BASE_DIR=self.project_root):27 call_command('compile_pyc')28 pyc_glob = self._find_pyc(self.project_root)29 self.assertTrue(len(pyc_glob) > 0)30 with self.settings(BASE_DIR=self.project_root):31 call_command('clean_pyc')32 def test_takes_path(self):33 out = six.StringIO()34 with self.settings(BASE_DIR=""):35 call_command('clean_pyc', path=self.project_root)36 pyc_glob = self._find_pyc(self.project_root)37 self.assertEqual(len(pyc_glob), 0)38 with self.settings(BASE_DIR=""):39 call_command('compile_pyc', verbosity=2, path=self.project_root, stdout=out)40 expected = ['Compiling %s...' % fn for fn in sorted(self._find_pyc(self.project_root, mask='*.py'))]41 output = out.getvalue().splitlines()42 self.assertEqual(expected, sorted(output))43 with self.settings(BASE_DIR=""):...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run dbt-osmosis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful