How to use test_depends method in tox

Best Python code snippet using tox_python

workspace_factory.py

Source:workspace_factory.py Github

copy

Full Screen

1import os2import shutil3from ..utils import temporary_directory4class workspace_factory(temporary_directory):5 def __init__(self, source_space='src', prefix=''):6 super(workspace_factory, self).__init__(prefix=prefix)7 self.source_space = source_space8 def __enter__(self):9 self.temporary_directory = super(workspace_factory, self).__enter__()10 self.workspace_factory = WorkspaceFactory(self.temporary_directory, self.source_space)11 return self.workspace_factory12 def __exit__(self, exc_type, exc_value, traceback):13 super(workspace_factory, self).__exit__(exc_type, exc_value, traceback)14class WorkspaceFactory(object):15 def __init__(self, workspace, source_space='src'):16 self.workspace = workspace17 self.source_space = os.path.join(self.workspace, source_space)18 self.packages = {}19 class Package(object):20 PACKAGE_XML_TEMPLATE = """\21<?xml version="1.0"?>22<package>23 <name>{name}</name>24 <version>0.0.0</version>25 <description>26 Description for {name}27 </description>28 <maintainer email="person@email.com">Firstname Lastname</maintainer>29 <license>MIT</license>30{depends_xml}31{export_xml}32</package>33"""34 PACKAGE_XML_EXPORT_TEMPLATE = """35 <export>36 <build_type>{build_type}</build_type>37 </export>"""38 CATKIN_CMAKELISTS_TEMPLATE = """39cmake_minimum_required(VERSION 2.8.12)40project({name})41find_package(catkin REQUIRED COMPONENTS {catkin_components})42catkin_package()"""43 CMAKE_CMAKELISTS_TEMPLATE = """44cmake_minimum_required(VERSION 2.8.12)45project({name})46{find_packages}47add_custom_target(install)"""48 CMAKE_CMAKELISTS_FIND_PACKAGE_TEMPLATE = """49find_package({name})"""50 def __init__(self, name, build_type, depends, build_depends, run_depends, test_depends):51 self.name = name52 self.build_type = build_type53 self.build_depends = (build_depends or []) + (depends or [])54 self.run_depends = (run_depends or []) + (depends or [])55 self.test_depends = (test_depends or [])56 def get_package_xml(self):57 # Get dependencies58 depends_xml = '\n'.join(59 [' <buildtool_depend>{0}</buildtool_depend>'.format(self.build_type)] +60 [' <build_depend>{0}</build_depend>'.format(x) for x in self.build_depends] +61 [' <run_depend>{0}</run_depend>'.format(x) for x in self.run_depends] +62 [' <test_depend>{0}</test_depend>'.format(x) for x in self.test_depends]63 )64 # Get exports section65 if self.build_type == 'catkin':66 export_xml = ''67 else:68 export_xml = self.PACKAGE_XML_EXPORT_TEMPLATE.format(build_type=self.build_type)69 # Format the package.xml template70 return self.PACKAGE_XML_TEMPLATE.format(71 name=self.name,72 depends_xml=depends_xml,73 export_xml=export_xml)74 def get_cmakelists_txt(self):75 if self.build_type == 'catkin':76 return self.CATKIN_CMAKELISTS_TEMPLATE.format(77 name=self.name,78 catkin_components=' '.join(self.build_depends))79 if self.build_type == 'cmake':80 find_packages = '\n'.join([81 self.CMAKE_CMAKELISTS_FIND_PACKAGE_TEMPLATE.format(name=name)82 for name in self.build_depends])83 return self.CMAKE_CMAKELISTS_TEMPLATE.format(84 name=self.name,85 find_packages=find_packages)86 def add_package(self, pkg_name, package_path):87 """Copy a static package into the workspace"""88 shutil.copytree(package_path, self.source_space)89 def create_package(90 self,91 pkg_name,92 build_type='cmake',93 depends=None,94 build_depends=None,95 run_depends=None,96 test_depends=None97 ):98 """Add a package to be generated in this workspace."""99 self.packages[pkg_name] = self.Package(pkg_name, build_type, depends, build_depends, run_depends, test_depends)100 def build(self):101 """Generate workspace paths and packages."""102 cwd = os.getcwd()103 if not os.path.isdir(self.workspace):104 if os.path.exists(self.workspace):105 raise RuntimeError("Cannot build workspace in '{0}' because it is a file".format(self.workspace))106 os.makedirs(self.workspace)107 if os.path.exists(self.source_space):108 print("WARNING: source space given to WorkspaceFactory exists, clearing before build()'ing")109 self.clear()110 os.makedirs(self.source_space)111 try:112 os.chdir(self.source_space)113 for name, pkg in self.packages.items():114 pkg_dir = os.path.join(self.source_space, name)115 os.makedirs(pkg_dir)116 pkg_xml_path = os.path.join(pkg_dir, 'package.xml')117 with open(pkg_xml_path, 'w') as f:118 f.write(pkg.get_package_xml())119 cmakelists_txt_path = os.path.join(pkg_dir, 'CMakeLists.txt')120 with open(cmakelists_txt_path, 'w') as f:121 f.write(pkg.get_cmakelists_txt())122 finally:123 os.chdir(cwd)124 def clear(self):125 if os.path.exists(self.workspace):...

Full Screen

Full Screen

test_views.py

Source:test_views.py Github

copy

Full Screen

...30 def test0006depends(self):31 '''32 Test depends.33 '''34 test_depends()35def suite():36 """37 Test Suite38 """39 test_suite = trytond.tests.test_tryton.suite()40 test_suite.addTests(41 unittest.TestLoader().loadTestsFromTestCase(TestViewDepend)42 )43 return test_suite44if __name__ == '__main__':...

Full Screen

Full Screen

test_views_depends.py

Source:test_views_depends.py Github

copy

Full Screen

...8 def test_views(self):9 "Test all tryton views"10 from trytond.tests.test_tryton import test_view11 test_view('shopkeeper')12 def test_depends(self):13 "Test missing depends on fields"14 from trytond.tests.test_tryton import test_depends...

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 tox 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