Best Python code snippet using pandera_python
test_arg_helpers.py
Source:test_arg_helpers.py
...33 actual = float_or_json_parser(target_json)34 assert np.array_equal(target, actual)35class TestStrOrIntParser:36 @pytest.mark.parametrize("value", [0, -1, 10, 100])37 def test_is_int(self, value):38 assert str_or_int_parser(str(value)) == value39 @pytest.mark.parametrize("value", ["10.1", "a", "None"])40 def test_is_string(self, value):41 assert str_or_int_parser(value) == value42class TestStrOrListParser:43 def test_is_list(self):44 target = [10.25, 1, 2]45 target_json = json.dumps(target)46 actual = str_or_list_parser(target_json)47 assert np.array_equal(target, actual)48 @pytest.mark.parametrize("value", ["", "a"])49 def test_is_string(self, value):50 assert str_or_list_parser(value) == value51 def test_json_not_list(self):52 target = {"a": 1, "b": 2}53 target_json = json.dumps(target)54 with pytest.raises(ValueError, match="Supplied JSON string not list"):55 str_or_list_parser(target_json)56class TestIntOrNoneParser:57 def test_is_none(self):58 assert int_or_none_parser("None") is None59 @pytest.mark.parametrize("value", [1, 2, -1])60 def test_is_int(self, value):61 assert int_or_none_parser(str(value)) == value62 @pytest.mark.parametrize("value", ["a", "10.1", "[]"])63 def test_bad_value(self, value):64 with pytest.raises(ValueError, match="int_or_none_parser failed on:"):65 int_or_none_parser(value)66class TestJSONEmptyIsNoneParser:67 @pytest.mark.parametrize("value", [[1, 2], {"a": 1, "b": 2}])68 def test_json_strings(self, value):69 value_json = json.dumps(value)70 assert value == json_empty_is_none_parser(value_json)71 @pytest.mark.parametrize("value", [[], dict()])72 def test_empty(self, value):73 value_json = json.dumps(value)74 assert json_empty_is_none_parser(value_json) is None
validators.py
Source:validators.py
...16 def is_artist(self,artist):17 return artist != None and artist != ""18 def is_fiser(self,fisier):19 return fisier.endswith(".txt")20def test_is_int(valid):21 durata = "123432543"22 assert valid.is_int(durata) == True23 durata2 = ""24 assert valid.is_int(durata2) == False25 durata = "12h5"26 assert valid.is_int(durata) == False27 durata = "ASDFW2s"28 assert valid.is_int(durata) == False29 durata = "2"30 assert valid.is_int(durata) == True31 durata = "-2"32 assert valid.is_int(durata) == False33def test_is_gen(valid):34 gen = "Comedie"35 assert valid.is_gen(gen) == True36 gen2 = "Concert"37 assert valid.is_gen(gen2) == True38 gen = "Balet"39 assert valid.is_gen(gen) == True40 gen = "Altele"41 assert valid.is_gen(gen) == True42 gen = " Comedie "43 assert valid.is_gen(gen) == False44 gen = "Altele1"45 assert valid.is_gen(gen) == False46 gen = "1234"47 assert valid.is_gen(gen) == False48def test_is_artist(valid):49 artist1 = None50 assert valid.is_artist(artist1) == False51 artist1 = "sadfdsawdes"52 assert valid.is_artist(artist1) == True53 artist1 = ""54 assert valid.is_artist(artist1) == False55def test():56 valid = Validators()57 test_is_int(valid)58 test_is_gen(valid)59 test_is_artist(valid)60 ...
zadanie_6_test.py
Source:zadanie_6_test.py
...3import pytest4class TestCube(unittest.TestCase):5 def test_is_true(self):6 self.assertEqual(czy_jest_pierwszÄ
(23), True)7 def test_is_int(self):8 self.assertRaises(TypeError, czy_jest_pierwszÄ
(5), True)9def test_is_true():10 assert True == czy_jest_pierwszÄ
(3)11def test_is_int():12 with pytest.raises(TypeError): #dziaÅa na odwrót, bÅÄ
d jak jest liczba, bo nie ma TypeError...
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!!