Example #1
0
 def test_is_uuid4_fail(self):
     # Version 1 UUID should not validate as version 4
     obj = '5245eb82-31e6-11e9-8bfa-d8cb8a1a56c7'
     with self.assertRaises(CheckError):
         Is(obj).uuid4
     with self.assertRaises(CheckError):
         Is('fluent').uuid4
Example #2
0
 def test_is_uuid1_fail(self):
     # Version 4 UUID should not validate as version 1
     obj = '9f9b0fc0-e3bb-43af-9894-7b73c83374d1'
     with self.assertRaises(CheckError):
         Is(obj).uuid1
     with self.assertRaises(CheckError):
         Is('fluent').uuid1
 def test_not_module(self):
     self.assertIsInstance(Is(123).not_module, Is)
     try:
         self.assertIsInstance(Is(unittest).not_module, Is)
         self.fail()
     except CheckError:
         pass
Example #4
0
 def test_is_not_number_fail(self):
     with self.assertRaises(CheckError):
         Is(123).not_number  # ints
     with self.assertRaises(CheckError):
         Is(float(123)).not_number  # floats
     with self.assertRaises(CheckError):
         Is(complex(33.44, 55.66)).not_number  # complex
 def test_not_runnable(self):
     obj = lambda x: x + 1
     self.assertIsInstance(Is(123).not_runnable, Is)
     try:
         Is(obj).not_runnable
         self.fail()
     except CheckError:
         pass
 def test_not_of_type(self):
     obj = 123
     self.assertIsInstance(Is(obj).not_of_type(str), Is)
     try:
         Is(obj).not_of_type(int)
         self.fail()
     except CheckError:
         pass
Example #7
0
 def test_is_not_falsy_fail(self):
     for item in self.falsy_values:
         obj = item
         try:
             Is(obj).not_falsy
             self.fail()
         except CheckError:
             pass
 def test_is_xml_pass(self):
     obj = """<Agenda>
  <type>gardening</type>
  <Activity>
    <type>cooking</type>
  </Activity>
 </Agenda>"""
     self.assertIsInstance(Is(obj).xml, Is)
Example #9
0
 def test_is_truthy_fail(self):
     for item in self.truthy_values:
         obj = not item
         try:
             Is(obj).truthy
             self.fail()
         except CheckError:
             pass
 def test_is_not_yaml_fail(self):
     obj = """
  ---
   doe: "a deer, a female deer"
   calling-birds:
     - louie
     - fred
  """.strip()
     with self.assertRaises(CheckError):
         Is(obj).not_yaml
 def test_is_not_set_pass(self):
     self.assertIsInstance(Is(42).not_set, Is)
 def test_is_set_fail(self):
     with self.assertRaises(CheckError):
         Is(42).set
Example #13
0
 def test_is_has_not_keys_fail(self):
     obj = {1: 'one', 2: 'two'}
     with self.assertRaises(CheckError):
         Is(obj).has_not_keys(*obj.keys())
Example #14
0
 def test_is_not_dict_fail(self):
     obj = dict()
     with self.assertRaises(CheckError):
         Is(obj).not_dict
 def test_is_set_pass(self):
     obj = set()
     self.assertIsInstance(Is(obj).set, Is)
 def test_is_not_intersects_pass(self):
     obj = {1, 2, 3, 4, 5}
     other_set = {-1, 100}
     self.assertIsInstance(Is(obj).not_intersects(other_set), Is)
 def test_is_not_superset_of_pass(self):
     obj = {1, 2, 3, 4, 5}
     subset = {1, 100, 3}
     self.assertIsInstance(Is(obj).not_superset_of(subset), Is)
 def test_is_subset_of_fail(self):
     obj = {1, 2, 100}
     full_set = {1, 2, 3, 4, 5}
     with self.assertRaises(CheckError):
         Is(obj).subset_of(full_set)
 def test_is_not_subset_of_pass(self):
     obj = {1, 2, 3}
     full_set = {1, 7}
     self.assertIsInstance(Is(obj).not_subset_of(full_set), Is)
Example #20
0
 def test_is_not_real_fail(self):
     with self.assertRaises(CheckError):
         Is('test').not_real
     with self.assertRaises(CheckError):
         Is(123.9).not_real
 def test_is_not_superset_of_fail(self):
     obj = {1, 2, 3, 4, 5}
     subset = {1, 2, 5}
     with self.assertRaises(CheckError):
         Is(obj).not_superset_of(subset)
Example #22
0
 def test_is_number_pass(self):
     self.assertIsInstance(Is(7).number, Is)
     Is(123).number  # ints
     Is(float(123)).number  # floats
     Is(complex(33.44, 55.66)).number  # complex
 def test_is_not_intersects_fail(self):
     obj = {1, 2, 3, 4, 5}
     other_set = {1, 2, 3, 9, 100}
     with self.assertRaises(CheckError):
         Is(obj).not_intersects(other_set)
Example #24
0
 def test_is_complex_pass(self):
     obj = complex(1.2, 3.4)
     self.assertIsInstance(Is(obj).complex, Is)
Example #25
0
 def test_is_not_dict_pass(self):
     obj = set()
     self.assertIsInstance(Is(obj).not_dict, Is)
Example #26
0
 def test_is_complex_fail(self):
     with self.assertRaises(CheckError):
         Is(123).complex
     with self.assertRaises(CheckError):
         Is(123.9).complex
Example #27
0
 def test_is_has_not_keys_pass(self):
     obj = {1: 'one', 2: 'two'}
     self.assertIsInstance(Is(obj).has_not_keys(7, 3), Is)
Example #28
0
 def test_is_not_complex_pass(self):
     self.assertIsInstance(Is(7).not_complex, Is)
     self.assertIsInstance(Is(7.0).not_complex, Is)
Example #29
0
 def test_is_dict_pass(self):
     obj = dict()
     self.assertIsInstance(Is(obj).dict, Is)
Example #30
0
 def test_is_not_complex_fail(self):
     with self.assertRaises(CheckError):
         Is(complex(1.2, 3.4)).not_complex