How to use is_valid method in hypothesis

Best Python code snippet using hypothesis

test_properties.py

Source:test_properties.py Github

copy

Full Screen

...779 pass780class TestProperties(unittest.TestCase):781 def test_Any(self):782 prop = Any()783 self.assertTrue(prop.is_valid(None))784 self.assertTrue(prop.is_valid(False))785 self.assertTrue(prop.is_valid(True))786 self.assertTrue(prop.is_valid(0))787 self.assertTrue(prop.is_valid(1))788 self.assertTrue(prop.is_valid(0.0))789 self.assertTrue(prop.is_valid(1.0))790 self.assertTrue(prop.is_valid(1.0+1.0j))791 self.assertTrue(prop.is_valid(""))792 self.assertTrue(prop.is_valid(()))793 self.assertTrue(prop.is_valid([]))794 self.assertTrue(prop.is_valid({}))795 self.assertTrue(prop.is_valid(Foo()))796 def test_Bool(self):797 prop = Bool()798 self.assertTrue(prop.is_valid(None))799 self.assertTrue(prop.is_valid(False))800 self.assertTrue(prop.is_valid(True))801 self.assertFalse(prop.is_valid(0))802 self.assertFalse(prop.is_valid(1))803 self.assertFalse(prop.is_valid(0.0))804 self.assertFalse(prop.is_valid(1.0))805 self.assertFalse(prop.is_valid(1.0+1.0j))806 self.assertFalse(prop.is_valid(""))807 self.assertFalse(prop.is_valid(()))808 self.assertFalse(prop.is_valid([]))809 self.assertFalse(prop.is_valid({}))810 self.assertFalse(prop.is_valid(Foo()))811 self.assertTrue(prop.is_valid(np.bool8(False)))812 self.assertTrue(prop.is_valid(np.bool8(True)))813 self.assertFalse(prop.is_valid(np.int8(0)))814 self.assertFalse(prop.is_valid(np.int8(1)))815 self.assertFalse(prop.is_valid(np.int16(0)))816 self.assertFalse(prop.is_valid(np.int16(1)))817 self.assertFalse(prop.is_valid(np.int32(0)))818 self.assertFalse(prop.is_valid(np.int32(1)))819 self.assertFalse(prop.is_valid(np.int64(0)))820 self.assertFalse(prop.is_valid(np.int64(1)))821 self.assertFalse(prop.is_valid(np.uint8(0)))822 self.assertFalse(prop.is_valid(np.uint8(1)))823 self.assertFalse(prop.is_valid(np.uint16(0)))824 self.assertFalse(prop.is_valid(np.uint16(1)))825 self.assertFalse(prop.is_valid(np.uint32(0)))826 self.assertFalse(prop.is_valid(np.uint32(1)))827 self.assertFalse(prop.is_valid(np.uint64(0)))828 self.assertFalse(prop.is_valid(np.uint64(1)))829 self.assertFalse(prop.is_valid(np.float16(0)))830 self.assertFalse(prop.is_valid(np.float16(1)))831 self.assertFalse(prop.is_valid(np.float32(0)))832 self.assertFalse(prop.is_valid(np.float32(1)))833 self.assertFalse(prop.is_valid(np.float64(0)))834 self.assertFalse(prop.is_valid(np.float64(1)))835 self.assertFalse(prop.is_valid(np.complex64(1.0+1.0j)))836 self.assertFalse(prop.is_valid(np.complex128(1.0+1.0j)))837 if hasattr(np, "complex256"):838 self.assertFalse(prop.is_valid(np.complex256(1.0+1.0j)))839 def test_Int(self):840 prop = Int()841 self.assertTrue(prop.is_valid(None))842 # TODO: self.assertFalse(prop.is_valid(False))843 # TODO: self.assertFalse(prop.is_valid(True))844 self.assertTrue(prop.is_valid(0))845 self.assertTrue(prop.is_valid(1))846 self.assertFalse(prop.is_valid(0.0))847 self.assertFalse(prop.is_valid(1.0))848 self.assertFalse(prop.is_valid(1.0+1.0j))849 self.assertFalse(prop.is_valid(""))850 self.assertFalse(prop.is_valid(()))851 self.assertFalse(prop.is_valid([]))852 self.assertFalse(prop.is_valid({}))853 self.assertFalse(prop.is_valid(Foo()))854 # TODO: self.assertFalse(prop.is_valid(np.bool8(False)))855 # TODO: self.assertFalse(prop.is_valid(np.bool8(True)))856 self.assertTrue(prop.is_valid(np.int8(0)))857 self.assertTrue(prop.is_valid(np.int8(1)))858 self.assertTrue(prop.is_valid(np.int16(0)))859 self.assertTrue(prop.is_valid(np.int16(1)))860 self.assertTrue(prop.is_valid(np.int32(0)))861 self.assertTrue(prop.is_valid(np.int32(1)))862 self.assertTrue(prop.is_valid(np.int64(0)))863 self.assertTrue(prop.is_valid(np.int64(1)))864 self.assertTrue(prop.is_valid(np.uint8(0)))865 self.assertTrue(prop.is_valid(np.uint8(1)))866 self.assertTrue(prop.is_valid(np.uint16(0)))867 self.assertTrue(prop.is_valid(np.uint16(1)))868 self.assertTrue(prop.is_valid(np.uint32(0)))869 self.assertTrue(prop.is_valid(np.uint32(1)))870 self.assertTrue(prop.is_valid(np.uint64(0)))871 self.assertTrue(prop.is_valid(np.uint64(1)))872 self.assertFalse(prop.is_valid(np.float16(0)))873 self.assertFalse(prop.is_valid(np.float16(1)))874 self.assertFalse(prop.is_valid(np.float32(0)))875 self.assertFalse(prop.is_valid(np.float32(1)))876 self.assertFalse(prop.is_valid(np.float64(0)))877 self.assertFalse(prop.is_valid(np.float64(1)))878 self.assertFalse(prop.is_valid(np.complex64(1.0+1.0j)))879 self.assertFalse(prop.is_valid(np.complex128(1.0+1.0j)))880 if hasattr(np, "complex256"):881 self.assertFalse(prop.is_valid(np.complex256(1.0+1.0j)))882 def test_Float(self):883 prop = Float()884 self.assertTrue(prop.is_valid(None))885 # TODO: self.assertFalse(prop.is_valid(False))886 # TODO: self.assertFalse(prop.is_valid(True))887 self.assertTrue(prop.is_valid(0))888 self.assertTrue(prop.is_valid(1))889 self.assertTrue(prop.is_valid(0.0))890 self.assertTrue(prop.is_valid(1.0))891 self.assertFalse(prop.is_valid(1.0+1.0j))892 self.assertFalse(prop.is_valid(""))893 self.assertFalse(prop.is_valid(()))894 self.assertFalse(prop.is_valid([]))895 self.assertFalse(prop.is_valid({}))896 self.assertFalse(prop.is_valid(Foo()))897 # TODO: self.assertFalse(prop.is_valid(np.bool8(False)))898 # TODO: self.assertFalse(prop.is_valid(np.bool8(True)))899 self.assertTrue(prop.is_valid(np.int8(0)))900 self.assertTrue(prop.is_valid(np.int8(1)))901 self.assertTrue(prop.is_valid(np.int16(0)))902 self.assertTrue(prop.is_valid(np.int16(1)))903 self.assertTrue(prop.is_valid(np.int32(0)))904 self.assertTrue(prop.is_valid(np.int32(1)))905 self.assertTrue(prop.is_valid(np.int64(0)))906 self.assertTrue(prop.is_valid(np.int64(1)))907 self.assertTrue(prop.is_valid(np.uint8(0)))908 self.assertTrue(prop.is_valid(np.uint8(1)))909 self.assertTrue(prop.is_valid(np.uint16(0)))910 self.assertTrue(prop.is_valid(np.uint16(1)))911 self.assertTrue(prop.is_valid(np.uint32(0)))912 self.assertTrue(prop.is_valid(np.uint32(1)))913 self.assertTrue(prop.is_valid(np.uint64(0)))914 self.assertTrue(prop.is_valid(np.uint64(1)))915 self.assertTrue(prop.is_valid(np.float16(0)))916 self.assertTrue(prop.is_valid(np.float16(1)))917 self.assertTrue(prop.is_valid(np.float32(0)))918 self.assertTrue(prop.is_valid(np.float32(1)))919 self.assertTrue(prop.is_valid(np.float64(0)))920 self.assertTrue(prop.is_valid(np.float64(1)))921 self.assertFalse(prop.is_valid(np.complex64(1.0+1.0j)))922 self.assertFalse(prop.is_valid(np.complex128(1.0+1.0j)))923 if hasattr(np, "complex256"):924 self.assertFalse(prop.is_valid(np.complex256(1.0+1.0j)))925 def test_Complex(self):926 prop = Complex()927 self.assertTrue(prop.is_valid(None))928 # TODO: self.assertFalse(prop.is_valid(False))929 # TODO: self.assertFalse(prop.is_valid(True))930 self.assertTrue(prop.is_valid(0))931 self.assertTrue(prop.is_valid(1))932 self.assertTrue(prop.is_valid(0.0))933 self.assertTrue(prop.is_valid(1.0))934 self.assertTrue(prop.is_valid(1.0+1.0j))935 self.assertFalse(prop.is_valid(""))936 self.assertFalse(prop.is_valid(()))937 self.assertFalse(prop.is_valid([]))938 self.assertFalse(prop.is_valid({}))939 self.assertFalse(prop.is_valid(Foo()))940 # TODO: self.assertFalse(prop.is_valid(np.bool8(False)))941 # TODO: self.assertFalse(prop.is_valid(np.bool8(True)))942 self.assertTrue(prop.is_valid(np.int8(0)))943 self.assertTrue(prop.is_valid(np.int8(1)))944 self.assertTrue(prop.is_valid(np.int16(0)))945 self.assertTrue(prop.is_valid(np.int16(1)))946 self.assertTrue(prop.is_valid(np.int32(0)))947 self.assertTrue(prop.is_valid(np.int32(1)))948 self.assertTrue(prop.is_valid(np.int64(0)))949 self.assertTrue(prop.is_valid(np.int64(1)))950 self.assertTrue(prop.is_valid(np.uint8(0)))951 self.assertTrue(prop.is_valid(np.uint8(1)))952 self.assertTrue(prop.is_valid(np.uint16(0)))953 self.assertTrue(prop.is_valid(np.uint16(1)))954 self.assertTrue(prop.is_valid(np.uint32(0)))955 self.assertTrue(prop.is_valid(np.uint32(1)))956 self.assertTrue(prop.is_valid(np.uint64(0)))957 self.assertTrue(prop.is_valid(np.uint64(1)))958 self.assertTrue(prop.is_valid(np.float16(0)))959 self.assertTrue(prop.is_valid(np.float16(1)))960 self.assertTrue(prop.is_valid(np.float32(0)))961 self.assertTrue(prop.is_valid(np.float32(1)))962 self.assertTrue(prop.is_valid(np.float64(0)))963 self.assertTrue(prop.is_valid(np.float64(1)))964 self.assertTrue(prop.is_valid(np.complex64(1.0+1.0j)))965 self.assertTrue(prop.is_valid(np.complex128(1.0+1.0j)))966 if hasattr(np, "complex256"):967 self.assertTrue(prop.is_valid(np.complex256(1.0+1.0j)))968 def test_String(self):969 prop = String()970 self.assertTrue(prop.is_valid(None))971 self.assertFalse(prop.is_valid(False))972 self.assertFalse(prop.is_valid(True))973 self.assertFalse(prop.is_valid(0))974 self.assertFalse(prop.is_valid(1))975 self.assertFalse(prop.is_valid(0.0))976 self.assertFalse(prop.is_valid(1.0))977 self.assertFalse(prop.is_valid(1.0+1.0j))978 self.assertTrue(prop.is_valid(""))979 self.assertFalse(prop.is_valid(()))980 self.assertFalse(prop.is_valid([]))981 self.assertFalse(prop.is_valid({}))982 self.assertFalse(prop.is_valid(Foo()))983 def test_Regex(self):984 with self.assertRaises(TypeError):985 prop = Regex()986 prop = Regex("^x*$")987 self.assertTrue(prop.is_valid(None))988 self.assertFalse(prop.is_valid(False))989 self.assertFalse(prop.is_valid(True))990 self.assertFalse(prop.is_valid(0))991 self.assertFalse(prop.is_valid(1))992 self.assertFalse(prop.is_valid(0.0))993 self.assertFalse(prop.is_valid(1.0))994 self.assertFalse(prop.is_valid(1.0+1.0j))995 self.assertTrue(prop.is_valid(""))996 self.assertFalse(prop.is_valid(()))997 self.assertFalse(prop.is_valid([]))998 self.assertFalse(prop.is_valid({}))999 self.assertFalse(prop.is_valid(Foo()))1000 def test_Seq(self):1001 with self.assertRaises(TypeError):1002 prop = Seq()1003 prop = Seq(Int)1004 self.assertTrue(prop.is_valid(None))1005 self.assertFalse(prop.is_valid(False))1006 self.assertFalse(prop.is_valid(True))1007 self.assertFalse(prop.is_valid(0))1008 self.assertFalse(prop.is_valid(1))1009 self.assertFalse(prop.is_valid(0.0))1010 self.assertFalse(prop.is_valid(1.0))1011 self.assertFalse(prop.is_valid(1.0+1.0j))1012 self.assertFalse(prop.is_valid(""))1013 self.assertTrue(prop.is_valid(()))1014 self.assertTrue(prop.is_valid([]))1015 self.assertTrue(prop.is_valid(np.array([])))1016 self.assertFalse(prop.is_valid(set([])))1017 self.assertFalse(prop.is_valid({}))1018 self.assertTrue(prop.is_valid((1, 2)))1019 self.assertTrue(prop.is_valid([1, 2]))1020 self.assertTrue(prop.is_valid(np.array([1, 2])))1021 self.assertFalse(prop.is_valid({1, 2}))1022 self.assertFalse(prop.is_valid({1: 2}))1023 self.assertFalse(prop.is_valid(Foo()))1024 df = pd.DataFrame([1, 2])1025 self.assertTrue(prop.is_valid(df.index))1026 self.assertTrue(prop.is_valid(df.iloc[0]))1027 def test_List(self):1028 with self.assertRaises(TypeError):1029 prop = List()1030 prop = List(Int)1031 self.assertTrue(prop.is_valid(None))1032 self.assertFalse(prop.is_valid(False))1033 self.assertFalse(prop.is_valid(True))1034 self.assertFalse(prop.is_valid(0))1035 self.assertFalse(prop.is_valid(1))1036 self.assertFalse(prop.is_valid(0.0))1037 self.assertFalse(prop.is_valid(1.0))1038 self.assertFalse(prop.is_valid(1.0+1.0j))1039 self.assertFalse(prop.is_valid(""))1040 self.assertFalse(prop.is_valid(()))1041 self.assertTrue(prop.is_valid([]))1042 self.assertFalse(prop.is_valid({}))1043 self.assertFalse(prop.is_valid(Foo()))1044 def test_Dict(self):1045 with self.assertRaises(TypeError):1046 prop = Dict()1047 prop = Dict(String, List(Int))1048 self.assertTrue(prop.is_valid(None))1049 self.assertFalse(prop.is_valid(False))1050 self.assertFalse(prop.is_valid(True))1051 self.assertFalse(prop.is_valid(0))1052 self.assertFalse(prop.is_valid(1))1053 self.assertFalse(prop.is_valid(0.0))1054 self.assertFalse(prop.is_valid(1.0))1055 self.assertFalse(prop.is_valid(1.0+1.0j))1056 self.assertFalse(prop.is_valid(""))1057 self.assertFalse(prop.is_valid(()))1058 self.assertFalse(prop.is_valid([]))1059 self.assertTrue(prop.is_valid({}))1060 self.assertFalse(prop.is_valid(Foo()))1061 def test_Tuple(self):1062 with self.assertRaises(TypeError):1063 prop = Tuple()1064 with self.assertRaises(TypeError):1065 prop = Tuple(Int)1066 prop = Tuple(Int, String, List(Int))1067 self.assertTrue(prop.is_valid(None))1068 self.assertFalse(prop.is_valid(False))1069 self.assertFalse(prop.is_valid(True))1070 self.assertFalse(prop.is_valid(0))1071 self.assertFalse(prop.is_valid(1))1072 self.assertFalse(prop.is_valid(0.0))1073 self.assertFalse(prop.is_valid(1.0))1074 self.assertFalse(prop.is_valid(1.0+1.0j))1075 self.assertFalse(prop.is_valid(""))1076 self.assertFalse(prop.is_valid(()))1077 self.assertFalse(prop.is_valid([]))1078 self.assertFalse(prop.is_valid({}))1079 self.assertFalse(prop.is_valid(Foo()))1080 self.assertTrue(prop.is_valid((1, "", [1, 2, 3])))1081 self.assertFalse(prop.is_valid((1.0, "", [1, 2, 3])))1082 self.assertFalse(prop.is_valid((1, True, [1, 2, 3])))1083 self.assertFalse(prop.is_valid((1, "", (1, 2, 3))))1084 self.assertFalse(prop.is_valid((1, "", [1, 2, "xyz"])))1085 def test_Instance(self):1086 with self.assertRaises(TypeError):1087 prop = Instance()1088 prop = Instance(Foo)1089 self.assertTrue(prop.is_valid(None))1090 self.assertFalse(prop.is_valid(False))1091 self.assertFalse(prop.is_valid(True))1092 self.assertFalse(prop.is_valid(0))1093 self.assertFalse(prop.is_valid(1))1094 self.assertFalse(prop.is_valid(0.0))1095 self.assertFalse(prop.is_valid(1.0))1096 self.assertFalse(prop.is_valid(1.0+1.0j))1097 self.assertFalse(prop.is_valid(""))1098 self.assertFalse(prop.is_valid(()))1099 self.assertFalse(prop.is_valid([]))1100 self.assertFalse(prop.is_valid({}))1101 self.assertTrue(prop.is_valid(Foo()))1102 self.assertFalse(prop.is_valid(Bar()))1103 self.assertFalse(prop.is_valid(Baz()))1104 def test_Instance_from_json(self):1105 class MapOptions(HasProps):1106 lat = Float1107 lng = Float1108 zoom = Int(12)1109 v1 = Instance(MapOptions).from_json(dict(lat=1, lng=2))1110 v2 = MapOptions(lat=1, lng=2)1111 self.assertTrue(v1.equals(v2))1112 def test_Interval(self):1113 with self.assertRaises(TypeError):1114 prop = Interval()1115 with self.assertRaises(ValueError):1116 prop = Interval(Int, 0.0, 1.0)1117 prop = Interval(Int, 0, 255)1118 self.assertTrue(prop.is_valid(None))1119 # TODO: self.assertFalse(prop.is_valid(False))1120 # TODO: self.assertFalse(prop.is_valid(True))1121 self.assertTrue(prop.is_valid(0))1122 self.assertTrue(prop.is_valid(1))1123 self.assertFalse(prop.is_valid(0.0))1124 self.assertFalse(prop.is_valid(1.0))1125 self.assertFalse(prop.is_valid(1.0+1.0j))1126 self.assertFalse(prop.is_valid(""))1127 self.assertFalse(prop.is_valid(()))1128 self.assertFalse(prop.is_valid([]))1129 self.assertFalse(prop.is_valid({}))1130 self.assertFalse(prop.is_valid(Foo()))1131 self.assertTrue(prop.is_valid(127))1132 self.assertFalse(prop.is_valid(-1))1133 self.assertFalse(prop.is_valid(256))1134 prop = Interval(Float, 0.0, 1.0)1135 self.assertTrue(prop.is_valid(None))1136 # TODO: self.assertFalse(prop.is_valid(False))1137 # TODO: self.assertFalse(prop.is_valid(True))1138 self.assertTrue(prop.is_valid(0))1139 self.assertTrue(prop.is_valid(1))1140 self.assertTrue(prop.is_valid(0.0))1141 self.assertTrue(prop.is_valid(1.0))1142 self.assertFalse(prop.is_valid(1.0+1.0j))1143 self.assertFalse(prop.is_valid(""))1144 self.assertFalse(prop.is_valid(()))1145 self.assertFalse(prop.is_valid([]))1146 self.assertFalse(prop.is_valid({}))1147 self.assertFalse(prop.is_valid(Foo()))1148 self.assertTrue(prop.is_valid(0.5))1149 self.assertFalse(prop.is_valid(-0.001))1150 self.assertFalse(prop.is_valid( 1.001))1151 def test_Either(self):1152 with self.assertRaises(TypeError):1153 prop = Either()1154 prop = Either(Interval(Int, 0, 100), Regex("^x*$"), List(Int))1155 self.assertTrue(prop.is_valid(None))1156 # TODO: self.assertFalse(prop.is_valid(False))1157 # TODO: self.assertFalse(prop.is_valid(True))1158 self.assertTrue(prop.is_valid(0))1159 self.assertTrue(prop.is_valid(1))1160 self.assertFalse(prop.is_valid(0.0))1161 self.assertFalse(prop.is_valid(1.0))1162 self.assertFalse(prop.is_valid(1.0+1.0j))1163 self.assertTrue(prop.is_valid(""))1164 self.assertFalse(prop.is_valid(()))1165 self.assertTrue(prop.is_valid([]))1166 self.assertFalse(prop.is_valid({}))1167 self.assertFalse(prop.is_valid(Foo()))1168 self.assertTrue(prop.is_valid(100))1169 self.assertFalse(prop.is_valid(-100))1170 self.assertTrue(prop.is_valid("xxx"))1171 self.assertFalse(prop.is_valid("yyy"))1172 self.assertTrue(prop.is_valid([1, 2, 3]))1173 self.assertFalse(prop.is_valid([1, 2, ""]))1174 def test_Enum(self):1175 with self.assertRaises(TypeError):1176 prop = Enum()1177 with self.assertRaises(TypeError):1178 prop = Enum("red", "green", 1)1179 with self.assertRaises(TypeError):1180 prop = Enum("red", "green", "red")1181 prop = Enum("red", "green", "blue")1182 self.assertTrue(prop.is_valid(None))1183 self.assertFalse(prop.is_valid(False))1184 self.assertFalse(prop.is_valid(True))1185 self.assertFalse(prop.is_valid(0))1186 self.assertFalse(prop.is_valid(1))1187 self.assertFalse(prop.is_valid(0.0))1188 self.assertFalse(prop.is_valid(1.0))1189 self.assertFalse(prop.is_valid(1.0+1.0j))1190 self.assertFalse(prop.is_valid(""))1191 self.assertFalse(prop.is_valid(()))1192 self.assertFalse(prop.is_valid([]))1193 self.assertFalse(prop.is_valid({}))1194 self.assertFalse(prop.is_valid(Foo()))1195 self.assertTrue(prop.is_valid("red"))1196 self.assertTrue(prop.is_valid("green"))1197 self.assertTrue(prop.is_valid("blue"))1198 self.assertFalse(prop.is_valid("RED"))1199 self.assertFalse(prop.is_valid("GREEN"))1200 self.assertFalse(prop.is_valid("BLUE"))1201 self.assertFalse(prop.is_valid(" red"))1202 self.assertFalse(prop.is_valid(" green"))1203 self.assertFalse(prop.is_valid(" blue"))1204 from bokeh.core.enums import LineJoin1205 prop = Enum(LineJoin)1206 self.assertTrue(prop.is_valid(None))1207 self.assertFalse(prop.is_valid(False))1208 self.assertFalse(prop.is_valid(True))1209 self.assertFalse(prop.is_valid(0))1210 self.assertFalse(prop.is_valid(1))1211 self.assertFalse(prop.is_valid(0.0))1212 self.assertFalse(prop.is_valid(1.0))1213 self.assertFalse(prop.is_valid(1.0+1.0j))1214 self.assertFalse(prop.is_valid(""))1215 self.assertFalse(prop.is_valid(()))1216 self.assertFalse(prop.is_valid([]))1217 self.assertFalse(prop.is_valid({}))1218 self.assertFalse(prop.is_valid(Foo()))1219 self.assertTrue(prop.is_valid("miter"))1220 self.assertTrue(prop.is_valid("round"))1221 self.assertTrue(prop.is_valid("bevel"))1222 self.assertFalse(prop.is_valid("MITER"))1223 self.assertFalse(prop.is_valid("ROUND"))1224 self.assertFalse(prop.is_valid("BEVEL"))1225 self.assertFalse(prop.is_valid(" miter"))1226 self.assertFalse(prop.is_valid(" round"))1227 self.assertFalse(prop.is_valid(" bevel"))1228 from bokeh.core.enums import NamedColor1229 prop = Enum(NamedColor)1230 self.assertTrue(prop.is_valid("red"))1231 self.assertTrue(prop.is_valid("Red"))1232 self.assertTrue(prop.is_valid("RED"))1233 def test_Color(self):1234 prop = Color()1235 self.assertTrue(prop.is_valid(None))1236 self.assertFalse(prop.is_valid(False))1237 self.assertFalse(prop.is_valid(True))1238 self.assertFalse(prop.is_valid(0))1239 self.assertFalse(prop.is_valid(1))1240 self.assertFalse(prop.is_valid(0.0))1241 self.assertFalse(prop.is_valid(1.0))1242 self.assertFalse(prop.is_valid(1.0+1.0j))1243 self.assertFalse(prop.is_valid(""))1244 self.assertFalse(prop.is_valid(()))1245 self.assertFalse(prop.is_valid([]))1246 self.assertFalse(prop.is_valid({}))1247 self.assertFalse(prop.is_valid(Foo()))1248 self.assertTrue(prop.is_valid((0, 127, 255)))1249 self.assertFalse(prop.is_valid((0, -127, 255)))1250 self.assertFalse(prop.is_valid((0, 127)))1251 self.assertFalse(prop.is_valid((0, 127, 1.0)))1252 self.assertFalse(prop.is_valid((0, 127, 255, 255)))1253 self.assertTrue(prop.is_valid((0, 127, 255, 1.0)))1254 self.assertTrue(prop.is_valid("#00aaff"))1255 self.assertTrue(prop.is_valid("#00AAFF"))1256 self.assertTrue(prop.is_valid("#00AaFf"))1257 self.assertFalse(prop.is_valid("00aaff"))1258 self.assertFalse(prop.is_valid("00AAFF"))1259 self.assertFalse(prop.is_valid("00AaFf"))1260 self.assertFalse(prop.is_valid("#00AaFg"))1261 self.assertFalse(prop.is_valid("#00AaFff"))1262 self.assertTrue(prop.is_valid("blue"))1263 self.assertTrue(prop.is_valid("BLUE"))1264 self.assertFalse(prop.is_valid("foobar"))1265 self.assertEqual(prop.transform((0, 127, 255)), "rgb(0, 127, 255)")1266 self.assertEqual(prop.transform((0, 127, 255, 0.1)), "rgba(0, 127, 255, 0.1)")1267 def test_DashPattern(self):1268 prop = DashPattern()1269 self.assertTrue(prop.is_valid(None))1270 self.assertFalse(prop.is_valid(False))1271 self.assertFalse(prop.is_valid(True))1272 self.assertFalse(prop.is_valid(0))1273 self.assertFalse(prop.is_valid(1))1274 self.assertFalse(prop.is_valid(0.0))1275 self.assertFalse(prop.is_valid(1.0))1276 self.assertFalse(prop.is_valid(1.0+1.0j))1277 self.assertTrue(prop.is_valid(""))1278 self.assertTrue(prop.is_valid(()))1279 self.assertTrue(prop.is_valid([]))1280 self.assertFalse(prop.is_valid({}))1281 self.assertFalse(prop.is_valid(Foo()))1282 self.assertTrue(prop.is_valid("solid"))1283 self.assertTrue(prop.is_valid("dashed"))1284 self.assertTrue(prop.is_valid("dotted"))1285 self.assertTrue(prop.is_valid("dotdash"))1286 self.assertTrue(prop.is_valid("dashdot"))1287 self.assertFalse(prop.is_valid("DASHDOT"))1288 self.assertTrue(prop.is_valid([1, 2, 3]))1289 self.assertFalse(prop.is_valid([1, 2, 3.0]))1290 self.assertTrue(prop.is_valid("1 2 3"))1291 self.assertFalse(prop.is_valid("1 2 x"))1292 def test_Size(self):1293 prop = Size()1294 self.assertTrue(prop.is_valid(None))1295 # TODO: self.assertFalse(prop.is_valid(False))1296 # TODO: self.assertFalse(prop.is_valid(True))1297 self.assertTrue(prop.is_valid(0))1298 self.assertTrue(prop.is_valid(1))1299 self.assertTrue(prop.is_valid(0.0))1300 self.assertTrue(prop.is_valid(1.0))1301 self.assertFalse(prop.is_valid(1.0+1.0j))1302 self.assertFalse(prop.is_valid(""))1303 self.assertFalse(prop.is_valid(()))1304 self.assertFalse(prop.is_valid([]))1305 self.assertFalse(prop.is_valid({}))1306 self.assertFalse(prop.is_valid(Foo()))1307 self.assertTrue(prop.is_valid(100))1308 self.assertTrue(prop.is_valid(100.1))1309 self.assertFalse(prop.is_valid(-100))1310 self.assertFalse(prop.is_valid(-0.001))1311 def test_Percent(self):1312 prop = Percent()1313 self.assertTrue(prop.is_valid(None))1314 # TODO: self.assertFalse(prop.is_valid(False))1315 # TODO: self.assertFalse(prop.is_valid(True))1316 self.assertTrue(prop.is_valid(0))1317 self.assertTrue(prop.is_valid(1))1318 self.assertTrue(prop.is_valid(0.0))1319 self.assertTrue(prop.is_valid(1.0))1320 self.assertFalse(prop.is_valid(1.0+1.0j))1321 self.assertFalse(prop.is_valid(""))1322 self.assertFalse(prop.is_valid(()))1323 self.assertFalse(prop.is_valid([]))1324 self.assertFalse(prop.is_valid({}))1325 self.assertFalse(prop.is_valid(Foo()))1326 self.assertTrue(prop.is_valid(0.5))1327 self.assertFalse(prop.is_valid(-0.001))1328 self.assertFalse(prop.is_valid( 1.001))1329 def test_Angle(self):1330 prop = Angle()1331 self.assertTrue(prop.is_valid(None))1332 # TODO: self.assertFalse(prop.is_valid(False))1333 # TODO: self.assertFalse(prop.is_valid(True))1334 self.assertTrue(prop.is_valid(0))1335 self.assertTrue(prop.is_valid(1))1336 self.assertTrue(prop.is_valid(0.0))1337 self.assertTrue(prop.is_valid(1.0))1338 self.assertFalse(prop.is_valid(1.0+1.0j))1339 self.assertFalse(prop.is_valid(""))1340 self.assertFalse(prop.is_valid(()))1341 self.assertFalse(prop.is_valid([]))1342 self.assertFalse(prop.is_valid({}))1343 self.assertFalse(prop.is_valid(Foo()))1344 def test_MinMaxBounds_with_no_datetime(self):1345 prop = MinMaxBounds(accept_datetime=False)1346 # Valid values1347 self.assertTrue(prop.is_valid('auto'))1348 self.assertTrue(prop.is_valid(None))1349 self.assertTrue(prop.is_valid((12, 13)))1350 self.assertTrue(prop.is_valid((-32, -13)))1351 self.assertTrue(prop.is_valid((12.1, 13.1)))1352 self.assertTrue(prop.is_valid((None, 13.1)))1353 self.assertTrue(prop.is_valid((-22, None)))1354 # Invalid values1355 self.assertFalse(prop.is_valid('string'))1356 self.assertFalse(prop.is_valid(12))1357 self.assertFalse(prop.is_valid(('a', 'b')))1358 self.assertFalse(prop.is_valid((13, 12)))1359 self.assertFalse(prop.is_valid((13.1, 12.2)))1360 self.assertFalse(prop.is_valid((datetime.date(2012, 10, 1), datetime.date(2012, 12, 2))))1361 def test_MinMaxBounds_with_datetime(self):1362 prop = MinMaxBounds(accept_datetime=True)1363 # Valid values1364 self.assertTrue(prop.is_valid((datetime.date(2012, 10, 1), datetime.date(2012, 12, 2))))1365 # Invalid values1366 self.assertFalse(prop.is_valid((datetime.date(2012, 10, 1), 22)))1367def test_HasProps_equals():1368 class Foo(HasProps):1369 x = Int(12)1370 y = String("hello")1371 z = List(Int, [1,2,3])1372 class FooUnrelated(HasProps):1373 x = Int(12)1374 y = String("hello")1375 z = List(Int, [1,2,3])1376 v = Foo().equals(Foo())1377 assert v is True1378 v = Foo(x=1).equals(Foo(x=1))1379 assert v is True1380 v = Foo(x=1).equals(Foo(x=2))...

Full Screen

Full Screen

test_validator.py

Source:test_validator.py Github

copy

Full Screen

1# encoding: utf-82# ---------------------------------------------------------------------------3# Copyright (C) 2008-2014, Enthought, Inc.4# Distributed under the terms of the BSD License. See COPYING.rst.5# ---------------------------------------------------------------------------6import unittest7import numpy as np8import validator9VERSION = '0.10.0'10class TestValidDimData(unittest.TestCase):11 def test_block(self):12 dim_data = ({'dist_type': 'b',13 'size': 50,14 'proc_grid_size': 2,15 'proc_grid_rank': 0,16 'start': 0,17 'stop': 10},)18 distbuffer = {'__version__': VERSION,19 'buffer': np.ones(10),20 'dim_data': dim_data}21 is_valid, msg = validator.validate(distbuffer)22 self.assertTrue(is_valid, msg)23 def test_cyclic(self):24 dim_data = ({'dist_type': 'c',25 'size': 50,26 'proc_grid_size': 2,27 'proc_grid_rank': 0,28 'start': 0},)29 distbuffer = {'__version__': VERSION,30 'buffer': np.ones(50),31 'dim_data': dim_data}32 is_valid, msg = validator.validate(distbuffer)33 self.assertTrue(is_valid, msg)34 def test_block_cyclic(self):35 dim_data = ({'dist_type': 'c',36 'size': 50,37 'proc_grid_size': 2,38 'proc_grid_rank': 1,39 'start': 5,40 'block_size': 5},)41 distbuffer = {'__version__': VERSION,42 'buffer': np.ones(50),43 'dim_data': dim_data}44 is_valid, msg = validator.validate(distbuffer)45 self.assertTrue(is_valid, msg)46 def test_unstructured(self):47 dim_data = ({'dist_type': 'u',48 'size': 50,49 'proc_grid_size': 2,50 'proc_grid_rank': 1,51 'indices': np.array([1, 22, 44, 49, 9, 33, 21], dtype=np.uint32)52 },)53 distbuffer = {'__version__': VERSION,54 'buffer': np.ones(len(dim_data[0]['indices'])),55 'dim_data': dim_data}56 is_valid, msg = validator.validate(distbuffer)57 self.assertTrue(is_valid, msg)58 def test_extra_process(self):59 dimdata = {60 'dist_type':'c',61 'size':3,62 'proc_grid_size':4,63 'proc_grid_rank':0,64 'start' : 0,65 }66 distbuffer = {'__version__': VERSION,67 'buffer' : b'a',68 'dim_data' : (dimdata,)}69 is_valid, msg = validator.validate(distbuffer)70 self.assertTrue(is_valid, msg)71 def test_empty_process(self):72 dimdata = {73 'dist_type':'c',74 'size':3,75 'proc_grid_size':4,76 'proc_grid_rank':3,77 'start' : 3,78 }79 distbuffer = {'__version__': VERSION,80 'buffer' : b'',81 'dim_data' : (dimdata,)}82 is_valid, msg = validator.validate(distbuffer)83 self.assertTrue(is_valid, msg)84 def test_empty_dict_alias(self):85 dimdata = {}86 distbuffer = {'__version__': VERSION,87 'buffer' : b'',88 'dim_data' : (dimdata,)}89 is_valid, msg = validator.validate(distbuffer)90 self.assertTrue(is_valid, msg)91class TestMissingKeys(unittest.TestCase):92 def test_missing_buffer(self):93 dimdata = {94 'dist_type':'c',95 'size':3,96 'proc_grid_size':4,97 'proc_grid_rank':3,98 'start' : 3,99 }100 distbuffer = {'__version__': VERSION,101 'dim_data' : (dimdata,)}102 is_valid, msg = validator.validate(distbuffer)103 self.assertTrue(not is_valid, msg)104 def test_missing_version(self):105 dimdata = {106 'dist_type':'c',107 'size':3,108 'proc_grid_size':4,109 'proc_grid_rank':3,110 'start' : 3,111 }112 distbuffer = {'buffer' : b'',113 'dim_data' : (dimdata,)}114 is_valid, msg = validator.validate(distbuffer)115 self.assertTrue(not is_valid, msg)116 def test_missing_dim_data(self):117 distbuffer = {'__version__': VERSION,118 'buffer' : b'',}119 is_valid, msg = validator.validate(distbuffer)120 self.assertTrue(not is_valid, msg)121class TestInvalidKeys(unittest.TestCase):122 def test_bad_buffer(self):123 dimdata = {124 'dist_type':'c',125 'size':3,126 'proc_grid_size':4,127 'proc_grid_rank':3,128 'start' : 3,129 }130 distbuffer = {'__version__': VERSION,131 'dim_data' : (dimdata,),132 'buffer' : [1,2,3,4],}133 is_valid, msg = validator.validate(distbuffer)134 self.assertTrue(not is_valid, msg)135 def test_bad_version(self):136 dimdata = {137 'dist_type':'c',138 'size':3,139 'proc_grid_size':4,140 'proc_grid_rank':3,141 'start' : 3,142 }143 distbuffer = {'__version__': 'v1.0.0alpha',144 'buffer' : b'',145 'dim_data' : (dimdata,)}146 is_valid, msg = validator.validate(distbuffer)147 self.assertTrue(not is_valid, msg)148class TestInvalidDimData(unittest.TestCase):149 def test_bad_dist_type(self):150 """Test stop > size."""151 dim_data = ({'dist_type': 'q',152 'size': 50,153 'proc_grid_size': 2,154 'proc_grid_rank': 0,155 'start': 0,156 'stop': 51},)157 distbuffer = {'__version__': VERSION,158 'buffer': np.ones(51),159 'dim_data': dim_data}160 is_valid, msg = validator.validate(distbuffer)161 self.assertFalse(is_valid, msg)162 def test_bad_block_stop_0(self):163 """Test stop > size."""164 dim_data = ({'dist_type': 'b',165 'size': 50,166 'proc_grid_size': 2,167 'proc_grid_rank': 0,168 'start': 0,169 'stop': 51},)170 distbuffer = {'__version__': VERSION,171 'buffer': np.ones(51),172 'dim_data': dim_data}173 is_valid, msg = validator.validate(distbuffer)174 self.assertFalse(is_valid, msg)175 def test_bad_block_stop_1(self):176 """Test stop < start."""177 dim_data = ({'dist_type': 'b',178 'size': 50,179 'proc_grid_size': 2,180 'proc_grid_rank': 0,181 'start': 10,182 'stop': 9},)183 distbuffer = {'__version__': VERSION,184 'buffer': np.ones((0,)),185 'dim_data': dim_data}186 is_valid, msg = validator.validate(distbuffer)187 self.assertFalse(is_valid, msg)188 def test_bad_block_start(self):189 """Test negative start."""190 dim_data = ({'dist_type': 'b',191 'size': 50,192 'proc_grid_size': 2,193 'proc_grid_rank': 0,194 'start': -1,195 'stop': 10},)196 distbuffer = {'__version__': VERSION,197 'buffer': np.ones(11),198 'dim_data': dim_data}199 is_valid, msg = validator.validate(distbuffer)200 self.assertFalse(is_valid, msg)201 def test_bad_block_padding(self):202 """Test padding not ints."""203 dim_data = ({'dist_type': 'b',204 'size': 50,205 'proc_grid_size': 2,206 'proc_grid_rank': 0,207 'start': 0,208 'stop': 10,209 'padding': ('a','b')},)210 distbuffer = {'__version__': VERSION,211 'buffer': np.ones(10),212 'dim_data': dim_data}213 is_valid, msg = validator.validate(distbuffer)214 self.assertFalse(is_valid, msg)215 def test_bad_cyclic_block_size(self):216 """Test negative block size in cyclic."""217 dim_data = ({'dist_type': 'c',218 'size': 100,219 'proc_grid_size': 3,220 'proc_grid_rank': 0,221 'start': 0,222 'block_size': -10},)223 distbuffer = {'__version__': VERSION,224 'buffer': np.ones(10),225 'dim_data': dim_data}226 is_valid, msg = validator.validate(distbuffer)227 self.assertFalse(is_valid, msg)228 def test_bad_unstructured_indices(self):229 """Test non-buffer for unstructured indices."""230 dim_data = ({'dist_type': 'u',231 'size': 100,232 'proc_grid_size': 2,233 'proc_grid_rank': 0,234 'indices': [1, 2, 3, 4]},)235 distbuffer = {'__version__': VERSION,236 'buffer': np.ones(4),237 'dim_data': dim_data}238 is_valid, msg = validator.validate(distbuffer)239 self.assertFalse(is_valid, msg)240class TestCornerCases(unittest.TestCase):241 def test_undistributed_padded_periodic(self):242 dim_data = ({'dist_type': 'b',243 'size': 10,244 'proc_grid_size': 1,245 'proc_grid_rank': 0,246 'start': 0,247 'stop': 10,248 'padding': (2,2),249 'periodic': True,},)250 distbuffer = {'__version__': VERSION,251 'buffer': np.ones(10),252 'dim_data': dim_data}253 is_valid, msg = validator.validate(distbuffer)...

Full Screen

Full Screen

validation.py

Source:validation.py Github

copy

Full Screen

1def valid_import_service(service):2 is_valid = True3 fail_count = 04 if service.serviceProduct is None:5 fail_count += 16 if not valid_ip(service.ip): # IP address validation7 fail_count += 18 if not valid_int(service.portNo, 0, 65535):9 fail_count += 110 if fail_count > 0:11 is_valid = False12 return is_valid13def valid_import_vuln_zap(vuln):14 is_valid = True15 fail_count = 016 # NO IP address on Zap, as the scans use URLS instead.17 vuln.hostName # name18 if not valid_int(vuln.port, 0, 65535):19 fail_count += 120 vuln.ssl # No validation21 vuln.vulnID # Should i validate?22 if vuln.vulnName is None or vuln.vulnName == '': # Has to have a name23 fail_count += 124 if not valid_int(vuln.severity, 0, 4):25 fail_count += 126 vuln.desc # No validation27 vuln.path # No validation28 vuln.solution # No validation29 vuln.ref # No validation30 if not valid_date_zap(vuln.date):31 fail_count += 132 if fail_count > 0:33 is_valid = False34 return is_valid35def valid_import_vuln_nes(vuln):36 is_valid = True37 fail_count = 038 if not valid_ip(vuln.host): # IP address validation39 fail_count += 140 if not string_length_check(vuln.hostName, 17): # 00:50:56:81:01:e341 fail_count += 142 if not valid_int(vuln.port, 0, 65535):43 fail_count += 144 vuln.ssl # No validation45 vuln.vulnID # Should i validate?46 if vuln.vulnName is None or vuln.vulnName == '': # Has to have a name47 fail_count += 148 if not valid_int(vuln.severity, 0, 4):49 fail_count += 150 vuln.desc # No validation51 vuln.path # No validation52 vuln.solution # No validation53 vuln.ref # No validation54 if not valid_date_nes(vuln.date):55 fail_count += 156 if fail_count > 0:57 is_valid = False58 return is_valid59def valid_import_vuln_nex(vuln):60 is_valid = True61 fail_count = 062 if not valid_ip(vuln.host): # IP address validation63 fail_count += 164 if not string_length_check(vuln.hostName, 12): # 00:50:56:81:01:e365 fail_count += 166 vuln.ssl # No validation67 vuln.vulnID # Should i validate?68 if vuln.vulnName is None or vuln.vulnName == '': # Has to have a name69 fail_count += 170 if not valid_int(vuln.severity, 0, 10):71 fail_count += 172 vuln.desc # No validation73 vuln.path # No validation74 vuln.solution # No validation75 vuln.ref # No validation76 if not valid_date_nex(vuln.date):77 fail_count += 178 if fail_count > 0:79 is_valid = False80 return is_valid81# Checks to see if a string is as long as it should be, for MAC address82def string_length_check(string, length):83 is_valid = False84 #print(string)85 if string is not None:86 if len(string) == length:87 is_valid = True88 return is_valid89# Checks to see if an int is within the required range90# Or if even an int91def valid_int(value, lower, upper):92 is_valid = False93 if value is not None:94 if value.isdigit(): # First check its actually a positive int95 if lower <= int(value) <= upper: # if its within boundaries96 is_valid = True97 return is_valid98# Checks for a valid IP address99# Hoping this works for both IPv4 and IPv6100def valid_ip(IP):101 is_valid = False102 # IPv4 19.117.63.126103 # IPv6 2001:0db8:85a3:0000:0000:8a2e:0370:7334104 if IP is not None:105 check4 = IP.split('.')106 check6 = IP.split(':')107 if len(check4) == 4: # Check if its a valid IPv4108 is_valid = True109 for i in check4:110 is_valid = is_valid and valid_int(i, 0, 255)111 if len(check6) == 8: # Check if its a valid IPv6112 is_valid = True113 for x in check6:114 for i in x:115 if i.isdigit():116 if 0 <= int(i) <= 9:117 is_valid = is_valid and True118 else:119 is_valid = is_valid and False120 else:121 if ord('a') <= ord(i) <= ord('f') or ord('A') <= ord(i) <= ord('F'):122 is_valid = is_valid and True123 else:124 is_valid = is_valid and False125 return is_valid126# Takes a date in the format "Fri, 29 Mar 2019 21:02:52"127# For zap128def valid_date_zap(date):129 is_valid = True130 months = dict(Jan='1', Feb='2', Mar='3', Apr='4', May='5', Jun='6', Jul='7',131 Aug='8', Sep='9', Oct='10', Nov='11', Dec=12)132 if date is None:133 is_valid = False134 else:135 bigSplit = date.split(" ")136 if len(bigSplit) < 4:137 is_valid = False138 else:139 day = bigSplit[1]140 year = bigSplit[3]141 if day.isdigit() and year.isdigit():142 if int(day) < 1 or int(day) > 31:143 is_valid = False144 month_word = bigSplit[2]145 month_date = months.get(month_word)146 if month_date is None:147 is_valid = False148 else:149 is_valid = False150 return is_valid151# Checks a date in the format 20160218T203218272'152# For nexpose153def valid_date_nex(date):154 is_valid = True155 if date is None:156 is_valid = False157 else:158 halves = date.split('T')159 if len(halves) != 2:160 is_valid = False161 else:162 if len(halves[0]) < 8:163 is_valid = False164 else:165 date_part = halves[0]166 year = date_part[0:4]167 month_date = date_part[4:6]168 day = date_part[6:8]169 if month_date.isdigit() and day.isdigit() and year.isdigit():170 if int(month_date) > 12 or int(month_date) < 1:171 is_valid = False172 if int(day) > 31 or int(day) < 1:173 is_valid = False174 else:175 is_valid = False176 return is_valid177# Checks for a date in the format: 'Mon Jul 1 11:33:11 2013'178# For nessus179def valid_date_nes(date):180 is_valid = True181 months = dict(Jan='1', Feb='2', Mar='3', Apr='4', May='5', Jun='6', Jul='7',182 Aug='8', Sep='9', Oct='10', Nov='11', Dec=12)183 if date is None:184 is_valid = False185 else:186 big_split = date.split(' ')187 if len(big_split) < 6:188 is_valid = False189 else:190 day = big_split[3]191 month_word = big_split[1]192 year = big_split[5]193 if day.isdigit() and year.isdigit():194 month_date = months.get(month_word)195 if month_date is None:196 is_valid = False197 if int(day) > 31 or int(day) < 1:198 is_valid = False199 else:200 is_valid = False...

Full Screen

Full Screen

isbn_verifier_test.py

Source:isbn_verifier_test.py Github

copy

Full Screen

2from isbn_verifier import is_valid3# Tests adapted from `problem-specifications//canonical-data.json`4class IsbnVerifierTest(unittest.TestCase):5 def test_valid_isbn(self):6 self.assertIs(is_valid("3-598-21508-8"), True)7 def test_invalid_isbn_check_digit(self):8 self.assertIs(is_valid("3-598-21508-9"), False)9 def test_valid_isbn_with_a_check_digit_of_10(self):10 self.assertIs(is_valid("3-598-21507-X"), True)11 def test_check_digit_is_a_character_other_than_x(self):12 self.assertIs(is_valid("3-598-21507-A"), False)13 def test_invalid_character_in_isbn(self):14 self.assertIs(is_valid("3-598-P1581-X"), False)15 def test_x_is_only_valid_as_a_check_digit(self):16 self.assertIs(is_valid("3-598-2X507-9"), False)17 def test_valid_isbn_without_separating_dashes(self):18 self.assertIs(is_valid("3598215088"), True)19 def test_isbn_without_separating_dashes_and_x_as_check_digit(self):20 self.assertIs(is_valid("359821507X"), True)21 def test_isbn_without_check_digit_and_dashes(self):22 self.assertIs(is_valid("359821507"), False)23 def test_too_long_isbn_and_no_dashes(self):24 self.assertIs(is_valid("3598215078X"), False)25 def test_too_short_isbn(self):26 self.assertIs(is_valid("00"), False)27 def test_isbn_without_check_digit(self):28 self.assertIs(is_valid("3-598-21507"), False)29 def test_check_digit_of_x_should_not_be_used_for_0(self):30 self.assertIs(is_valid("3-598-21515-X"), False)31 def test_empty_isbn(self):32 self.assertIs(is_valid(""), False)33 def test_input_is_9_characters(self):34 self.assertIs(is_valid("134456729"), False)35 def test_invalid_characters_are_not_ignored(self):36 self.assertIs(is_valid("3132P34035"), False)37 def test_input_is_too_long_but_contains_a_valid_isbn(self):38 self.assertIs(is_valid("98245726788"), False)39if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run hypothesis automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful