Best Python code snippet using Testify_python
test_sendemail.py
Source:test_sendemail.py
...32 }33 }""")34 self.assertEqual(fix, self.gen_almanac(46, 32))35 36 def run_fixture(self, subject_line, test_fixture):37 sub = Command.get_subject(test_fixture)38 self.assertEqual(subject_line, sub)39 def test_good_weather(self):40 ## If its nice out, either sunny (or clear)41 sunny_fixture = dict(42 current_observation=dict(43 temp_f=10.0,44 weather="Sunny",45 precip_today_in="0.0", ## This actually how wunderground represents the data... as as string.. not a float because datatypes (or consistenscy) just dont matter to them ;)46 ),47 almanac=self.gen_almanac(10, 10)48 )49 self.run_fixture(Subject.GOOD, sunny_fixture)50 clear_fixture = dict(51 current_observation=dict(52 temp_f=10.0,53 weather="Clear",54 precip_today_in="0.0", ## This actually how wunderground represents the data... as as string.. not a float because datatypes (or consistenscy) just dont matter to them ;)55 ),56 almanac=self.gen_almanac(10, 10)57 )58 59 self.run_fixture(Subject.GOOD, clear_fixture)60 ## or 5 degrees warmer than average61 warm_fixture = dict(62 current_observation=dict(63 temp_f=15.0,64 weather="Clear",65 precip_today_in="0.0", ## This actually how wunderground represents the data... as as string.. not a float because datatypes (or consistenscy) just dont matter to them ;)66 ),67 almanac=self.gen_almanac(10, 10)68 )69 self.run_fixture(Subject.GOOD, warm_fixture)70 def test_bad_weather(self):71 ## or 5 degrees cooler than average72 cold_fixture = dict(73 current_observation=dict(74 temp_f=5.0,75 weather="Something not clear/sunny",76 precip_today_in="0.0", ## This actually how wunderground represents the data... as as string.. not a float because datatypes (or consistenscy) just dont matter to them ;)77 ),78 almanac=self.gen_almanac(10, 10)79 )80 self.run_fixture(Subject.BAD, cold_fixture)81 ## or precipitating82 precipitating_fixture = dict(83 current_observation=dict(84 temp_f=10.0,85 weather="Something not clear/sunny",86 precip_today_in="1.0", ## This actually how wunderground represents the data... as as string.. not a float because datatypes (or consistenscy) just dont matter to them ;)87 ),88 almanac=self.gen_almanac(10, 10)89 )90 self.run_fixture(Subject.BAD, precipitating_fixture)91 def test_neutral_weather(self):92 ## All other conditions are neutral93 neutral_fixture = dict(94 current_observation=dict(95 temp_f=10.0,96 weather="Something not clear/sunny",97 precip_today_in="0.0", ## This actually how wunderground represents the data... as as string.. not a float because datatypes (or consistenscy) just dont matter to them ;)98 ),99 almanac=self.gen_almanac(10, 10)100 )101 self.run_fixture(Subject.NEUTRAL, neutral_fixture)102 103 ...
test_vcf_diff.py
Source:test_vcf_diff.py
...13 # Single reference vcf with lots of bases14 self.full_vcf = join(fixpath,'base_caller','fullsample','fullsample.bam.vcf')15 self.full_vcf_diff = join(fixpath,'vcf_diff','fullsample.vcf.diff')16 self.fixture2 = (self.full_vcf,self.full_vcf_diff)17 def run_fixture( self, vcf, diff_file ):18 output = self.run_vcf_diff( vcf )19 with open(diff_file) as fh:20 eq_( fh.read(), output, "Output did not match expected output from file {0}".format(diff_file) )21 def run_vcf_diff( self, vcffile, *args, **kwargs ):22 import subprocess23 script = 'vcf_diff'24 cmd = [script,vcffile]25 print "Running {0}".format(' '.join(cmd))26 try:27 return compat.check_output( cmd, stderr=subprocess.STDOUT )28 except subprocess.CalledProcessError as e:29 return e.output30class TestFunctional(Base):31 def test_fixtures( self ):32 self.run_fixture( *self.fixture1 )...
test_config.py
Source:test_config.py
...12 (["--debug"], {"TEST_CONFIG_DEBUG": ""}, {"debug": True}),13 ],14)15def test_config_program(run_fixture, args, env, expected):16 p = run_fixture("config.py", args, env)17 loaded = json.loads(p.stdout)18 assert loaded == expected19def test_key_program(run_fixture):20 p = run_fixture("key.py", [], {})21 loaded = p.stdout.strip().split("\n")22 print(loaded)23 assert loaded == [24 "['foo', 'baz']",25 "['foo', 'bar']",26 "['bar', 'baz']",...
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!!