예제 #1
0
 def test_check_dont(self):
     check(None).dont.exists()
     check(1).dont.is_None()
     self.assertRaises(CheckError, check(3).dont.exists)
     # Dont only applies once
     check(None).dont.exists().is_None()
     # Chaining dont's
     check(None).dont.exists().dont.exists()
예제 #2
0
 def check(self, free_vars, code_text):
     tree = parse_statement(code_text)
     global_vars, all_bindings = varbindings.annotate(tree)
     self.assertEquals(set(global_vars.iterkeys()), set(free_vars))
     logged = pycheck.check(tree, all_bindings)
     assert_sets_equal(
         sorted([(error, node.lineno) for error, node in logged]), sorted(find_expected_errors(code_text))
     )
예제 #3
0
파일: basic.py 프로젝트: jalopez/PyCheck
def with_print(param1=None, param2=None):
    check(param1, "param1").exists()
    check(param2, "param2").dont.exists()
예제 #4
0
 def test_is_number_with_booleans(self):
     check(True).is_int()
     check(1).equals(True)
     check(0).equals(False)
     check(2).dont.equals(False).dont.equals(True)
     check(-1).dont.equals(False)
예제 #5
0
 def test_is_int(self):
     check(0).is_int()
     check(2.3).dont.is_int()
     check("hello").dont.is_int()
     self.assertRaises(CheckError, check(2.3).is_int)
     self.assertRaises(CheckError, check("hello").is_int)
예제 #6
0
 def test_is_number(self):
     check(0).is_number()
     check("hello").dont.is_number()
     self.assertRaises(CheckError, check("hello").is_number)
     self.assertRaises(CheckError, check(3).dont.is_number)
예제 #7
0
 def test_accept_number(self):
     check(3)
예제 #8
0
 def test_ge(self):
     check(2).ge(2).ge(1)
     check(1).dont.ge(2)
     check(1).gt(-2).ge(1)
예제 #9
0
 def test_exists(self):
     check(1).exists() 
     self.assertRaises(CheckError, check(None).exists)
예제 #10
0
 def test_distinct(self):
     check(3).distinct(None)
     check("a").distinct("b")
     check(3).dont.distinct(3)
예제 #11
0
 def test_equals(self):
     check(None).equals(None)
     check("hello").equals("hello")
     check(2).equals(2)
     check(2).dont.equals(3)
     check(2).dont.equals("2")
예제 #12
0
 def my_func(param1):
     check(param1).exists()
예제 #13
0
 def test_check_with_variable_name(self):
     try:
         my_var = 3
         check(my_var, 'my_var').dont.exists()
     except CheckError, e:
         self.assertEquals(str(e), 'my_var should not exist')
예제 #14
0
 def test_check_chain(self):
     check(1).exists().exists()
     self.assertRaises(CheckError, check(3).exists().is_None)
예제 #15
0
 def test_is_None(self):
     check(None).is_None()
     self.assertRaises(CheckError, check(3).is_None)
예제 #16
0
파일: basic.py 프로젝트: jalopez/PyCheck
def basic(param1, param2=None):
    check(param1, "param1").exists()
    check(param2, "param2").dont.exists()
예제 #17
0
파일: basic.py 프로젝트: jalopez/PyCheck
def with_decorator(param1=None):
    check(param1, "param1").exists()
예제 #18
0
 def test_gt(self):
     check(3).gt(2)
     check("b").gt("a")
     check("2").gt(1)
     check(1).dont.gt("a")
     check(1).gt(0.99)