Best Python code snippet using autotest_python
package.py
Source:package.py  
...116        if self.run_tests:117            test_bin = lambda testname: join_path(prefix.bin, testname)118            test_graph = lambda graphname: join_path(prefix.share, graphname)119            graph = test_graph('4elt.graph')120            os.system('%s %s' % (test_bin('mtest'), graph))121            os.system('%s %s 40' % (test_bin('kmetis'), graph))122            os.system('%s %s' % (test_bin('onmetis'), graph))123            graph = test_graph('test.mgraph')124            os.system('%s %s 2' % (test_bin('pmetis'), graph))125            os.system('%s %s 2' % (test_bin('kmetis'), graph))126            os.system('%s %s 5' % (test_bin('kmetis'), graph))127            graph = test_graph('metis.mesh')128            os.system('%s %s 10' % (test_bin('partnmesh'), graph))129            os.system('%s %s 10' % (test_bin('partdmesh'), graph))130            os.system('%s %s' % (test_bin('mesh2dual'), graph))131            # FIXME: The following code should replace the testing code in the132            # block above since it causes installs to fail when one or more of133            # the Metis tests fail, but it currently doesn't work because the134            # 'mtest', 'onmetis', and 'partnmesh' tests return error codes that135            # trigger false positives for failure.136            """137            Executable(test_bin('mtest'))(test_graph('4elt.graph'))138            Executable(test_bin('kmetis'))(test_graph('4elt.graph'), '40')139            Executable(test_bin('onmetis'))(test_graph('4elt.graph'))140            Executable(test_bin('pmetis'))(test_graph('test.mgraph'), '2')141            Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '2')142            Executable(test_bin('kmetis'))(test_graph('test.mgraph'), '5')143            Executable(test_bin('partnmesh'))(test_graph('metis.mesh'), '10')144            Executable(test_bin('partdmesh'))(test_graph('metis.mesh'), '10')145            Executable(test_bin('mesh2dual'))(test_graph('metis.mesh'))146            """147    @when('@5:')148    def install(self, spec, prefix):149        source_directory = self.stage.source_path150        build_directory = join_path(source_directory, 'build')151        options = std_cmake_args[:]152        options.append('-DGKLIB_PATH:PATH=%s/GKlib' % source_directory)153        options.append('-DCMAKE_INSTALL_NAME_DIR:PATH=%s/lib' % prefix)154        if '+shared' in spec:155            options.append('-DSHARED:BOOL=ON')156        if '+debug' in spec:157            options.extend(['-DDEBUG:BOOL=ON',158                            '-DCMAKE_BUILD_TYPE:STRING=Debug'])159        if '+gdb' in spec:...test_r2surface.py
Source:test_r2surface.py  
...63        ref = json.loads(fin.read())64    r2_surf.core.file = os.path.basename(r2_surf.core.file)65    assert asdict(r2_surf.core) == ref66@pytest.mark.parametrize("test_bin", test_bins)67def test_bin(test_bin: str, datadir: Path) -> None:68    src_file = str(datadir / test_bin)69    ref_file = test_bin.split(".")[0] + "_bin.json"70    r2 = r2pipe.open(src_file)71    r2_surf = R2Surface(r2)72    with open(ref_file, "r") as fin:73        ref = json.loads(fin.read())74    assert {key: value for key, value in asdict(r2_surf.bin).items() if value is not None} == ref75@pytest.mark.parametrize("test_bin", test_bins)76def test_entry_point(test_bin: str, datadir: Path) -> None:77    src_file = str(datadir / test_bin)78    ref_file = test_bin.split(".")[0] + "_entry_point.json"79    r2 = r2pipe.open(src_file)80    r2_surf = R2Surface(r2)81    with open(ref_file, "r") as fin:...stitch.py
Source:stitch.py  
...3from ifcb.io.path import Filesystem4from ifcb.io.stitching import stitch, find_pairs, StitchedBin5import os6import sys7def test_bin(pid):8    #client = Client()9    client = Filesystem(['../exampleData'])10    catch = False11    dir = os.path.join('stitch',ifcb.lid(pid))12    try:13        os.mkdir(dir)14    except:15        pass16    unstitched = client.resolve(pid)17    stitched = StitchedBin(unstitched)18    print stitched19    pairs = list(find_pairs(unstitched))20    for target,ignore in pairs:21        t = stitched.target(target)22        print 'Got %s' % t23        basename = ifcb.lid(t.pid)24        t.image().save(os.path.join(dir,basename+'.png'),'png')25        t.mask().save(os.path.join(dir,basename+'_mask.png'),'png')26        t.stitch_raw().save(os.path.join(dir,basename+'_raw.png'),'png')27def test_rotate(pid):28    for client,fn in zip([Client(), Filesystem(['../exampleData'])],['target_web','target_file']):29        target = client.resolve(pid)30        print target.info31        fn = os.path.join('/Users/jfutrelle/Pictures',fn+'.png')32        target.image().save(fn,'png')33        print 'saved %s' % fn34        35if __name__=='__main__':36    #test_bin('http://ifcb-data.whoi.edu/IFCB5_2010_273_135001')37    #test_bin('http://ifcb-data.whoi.edu/IFCB1_2011_294_114650')38    #test_bin('http://ifcb-data.whoi.edu/IFCB1_2011_282_235113')39    #test_bin('http://ifcb-data.whoi.edu/IFCB5_2010_264_121939')40    #test_bin('http://ifcb-data.whoi.edu/IFCB1_2011_287_152253')41    #test_bin('http://ifcb-data.whoi.edu/IFCB1_2011_295_022253')42    #test_bin('http://ifcb-data.whoi.edu/IFCB5_2010_273_121647')43    #test_bin('http://ifcb-data.whoi.edu/IFCB5_2010_242_133222')44    #test_bin('http://ifcb-data.whoi.edu/IFCB1_2011_297_142938')45    #test_bin('http://ifcb-data.whoi.edu/IFCB5_2011_305_135951')46    test_bin('http://ifcb-data.whoi.edu/IFCB5_2010_264_102403')47    #test_bin('http://ifcb-data.whoi.edu/IFCB1_2011_231_182610')...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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
