Best Python code snippet using autotest_python
tests_base.py
Source:tests_base.py
...54 self.assertEqual(response.status_code, 404)55 def test_dir_up(self):56 response = self.client.get('/../index/')57 self.assertEqual(response.status_code, 404)58 def test_same_dir(self):59 response = self.client.get('/./test2/')60 self.assertEqual(response.status_code, 404)61 def test_redirect_wo_trailing_slash(self):62 response = self.client.get('/test2')63 self.assertRedirects(response, '/test2/', status_code=301)64 @override_settings(65 DEBUG=True66 )67 def test_not_supressing_errors_in_debug(self):68 with self.assertRaises(TemplateDoesNotExist):69 self.client.get('/test-rocket-cat-does-not-exists/')70 @override_settings(71 DEBUG=False72 )...
test_flake8_pre_commit_hook.py
Source:test_flake8_pre_commit_hook.py
...31@pytest.fixture32def with_flake8_in_subdir(tmp_path):33 staged_files = ['.flake8', 'test.py', 'subdir/.flake8', 'subdir/test2.py']34 return make_tmp_files(tmp_path, staged_files)35def test_same_dir(in_same_dir, tmp_path):36 assert tmp_path.as_posix() in find_dirs_to_run_flake(in_same_dir)37def test_with_sub_dir(with_sub_dir, tmp_path):38 expected = [f for f in with_sub_dir if f.endswith('.py')]39 flake8_map = find_dirs_to_run_flake(with_sub_dir)40 assert tmp_path.as_posix() in flake8_map41 assert flake8_map[tmp_path.as_posix()] == expected42def test_with_two_flake_files(with_flake8_in_subdir, tmp_path):43 flake8_map = find_dirs_to_run_flake(with_flake8_in_subdir)44 assert [Path(f).name for f in flake8_map[tmp_path.as_posix()]] == ['test.py']45 other_key = tmp_path.joinpath('subdir').as_posix()46 assert [Path(f).name for f in flake8_map[other_key]] == ['test2.py']...
package_to_single_test.py
Source:package_to_single_test.py
...8 )9def get_tmp_path():10 return Path(__file__).parent / "data" / "tmp"11class PackageToSingleText(unittest.TestCase):12 def test_same_dir(self):13 package_to_single(get_mono_path())14 out_file = get_mono_path().with_suffix(".glyphs")15 assert out_file.is_file()16 # TODO: Check against original file?17 out_file.unlink()18 def test_with_output_dir(self):19 out_dir = get_tmp_path()20 package_to_single(get_mono_path(), out_dir)21 out_file = out_dir / "JetBrainsMono-Italic.glyphs"22 assert out_file.is_file()23 def test_with_output_file(self):24 out_file = get_tmp_path() / "custom.glyphs"25 package_to_single(get_mono_path(), out_file)26 assert out_file.is_file()...
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!!