Best Python code snippet using autotest_python
test_validator.py
Source:test_validator.py
1"""2.. codeauthor:: Tsuyoshi Hombashi <tsuyoshi.hombashi@gmail.com>3"""4import platform5import pytest6import pytablereader as ptr7from pytablereader._constant import SourceType8from pytablereader._validator import FileValidator, TextValidator, UrlValidator, is_fifo9class Test_FileValidator_validate:10 @pytest.mark.parametrize(["value"], [["test"]])11 def test_normal(self, tmpdir, value):12 p_file_path = tmpdir.join(value)13 with open(str(p_file_path), "w"):14 pass15 validator = FileValidator(str(p_file_path))16 assert validator.source_type == SourceType.FILE17 validator.validate()18 @pytest.mark.parametrize(19 ["value", "expected"], [[None, ptr.InvalidFilePathError], ["", ptr.InvalidFilePathError]]20 )21 def test_exception_null(self, value, expected):22 validator = FileValidator(value)23 with pytest.raises(expected):24 validator.validate()25 @pytest.mark.parametrize(["value", "expected"], [["te\0st", ptr.InvalidFilePathError]])26 def test_exception_invalid_path(self, tmpdir, value, expected):27 validator = FileValidator(value)28 with pytest.raises(expected):29 validator.validate()30class Test_TextValidator_validate:31 @pytest.mark.parametrize(["value"], [["test"]])32 def test_normal(self, value):33 validator = TextValidator(value)34 assert validator.source_type == SourceType.TEXT35 validator.validate()36 @pytest.mark.parametrize(["value", "expected"], [[None, ptr.DataError], ["", ptr.DataError]])37 def test_exception(self, value, expected):38 validator = TextValidator(value)39 with pytest.raises(expected):40 validator.validate()41class Test_UrlValidator_validate:42 @pytest.mark.parametrize(["value"], [["http://www.google.com"], ["https://github.com/"]])43 def test_normal(self, value):44 validator = UrlValidator(value)45 assert validator.source_type == SourceType.URL46 validator.validate()47 @pytest.mark.parametrize(48 ["value", "expected"],49 [[None, ptr.UrlError], ["", ptr.UrlError], ["www.google.com", ptr.UrlError]],50 )51 def test_exception(self, value, expected):52 validator = UrlValidator(value)53 with pytest.raises(expected):54 validator.validate()55class Test_is_fifo:56 @pytest.mark.skipif(57 platform.system() == "Windows",58 reason="platform dependent tests: only failed at GitHub Actions",59 )60 def test_filename_too_long(self):...
test_not_supported.py
Source:test_not_supported.py
...33def test_is_symlink():34 assert not S3Path('/fake-bucket/fake-key').is_symlink()35def test_is_socket():36 assert not S3Path('/fake-bucket/fake-key').is_socket()37def test_is_fifo():38 assert not S3Path('/fake-bucket/fake-key').is_fifo()39def test_is_block_device():40 path = S3Path('/fake-bucket/fake-key')41 with pytest.raises(NotImplementedError):42 path.is_block_device()43def test_is_char_device():44 path = S3Path('/fake-bucket/fake-key')45 with pytest.raises(NotImplementedError):46 path.is_char_device()47def test_lstat():48 path = S3Path('/fake-bucket/fake-key')49 with pytest.raises(NotImplementedError):50 path.lstat()51def test_resolve():...
test_system.py
Source:test_system.py
...15 testdir.monkeypatch.setenv(key, value)16 setenv_if_not_none("A", env_a)17 setenv_if_not_none("B", env_b)18 assert environ_get_first(("A", "B")) == env_expected19def test_is_fifo(testdir: TestDir) -> None:20 fifo_path = make_jobserver(testdir.tmpdir, "jobserver_fifo", 0)21 assert is_fifo(fifo_path) is True22 not_fifo_path = testdir.makefile(".txt", jobserver="X")23 assert is_fifo(not_fifo_path) is False24def test_is_rw_ok(testdir: TestDir) -> None:25 fifo_path = make_jobserver(testdir.tmpdir, "jobserver_fifo", 0)26 assert is_rw_ok(fifo_path) is True...
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!!