예제 #1
0
 def test_it_has_subclass_features_for_specific_messages(self):
     m = self.MyMessage(100, near_cookie_monster=True, has_cookie=False)
     expect(m[0]) == 100
     expect(m['health']) == 100
     expect(m[1]) == m['has_cookie'] == False
     expect(m[2]) == m['near_cookie_monster'] == True
     expect('health' in m).to.be_truthy()
예제 #2
0
 def test_it_can_generate_json_rpc(self):
     m = self.MyMessage(100, True, False, id=1337)
     expect(m.to_network()) == {
         "method": 'my_message',
         "params": [100, True, False, 0],
         "id": '1337',
     }
예제 #3
0
 def test_it_can_generate_json_rpc(self):
     m = self.MyMessage(100, True, False, id=1337)
     expect(m.to_network()) == {
         "method": 'my_message',
         "params": [100, True, False, 0],
         "id": '1337',
     }
예제 #4
0
 def test_it_can_create_message_from_json_rpc(self):
     m = self.MyMessage.create({
         'method': 'my_message',
         'params': [100, True, False, 0],
         'id': 1337,
     })
     expect(m) == self.MyMessage(100, True, False, id=1337)
예제 #5
0
 def test_it_has_subclass_features_for_specific_messages(self):
     m = self.MyMessage(100, near_cookie_monster=True, has_cookie=False)
     expect(m[0]) == 100
     expect(m['health']) == 100
     expect(m[1]) == m['has_cookie'] == False
     expect(m[2]) == m['near_cookie_monster'] == True
     expect('health' in m).to.be_truthy()
예제 #6
0
 def test_it_can_create_message_from_json_rpc(self):
     m = self.MyMessage.create({
         'method': 'my_message',
         'params': [100, True, False, 0],
         'id': 1337,
     })
     expect(m) == self.MyMessage(100, True, False, id=1337)
예제 #7
0
파일: test_exam.py 프로젝트: Lujaw/exam
    def test_imports_all_the_decorators(self):
        import exam.decorators

        for decorator in self.DECORATORS:
            from_decorators = getattr(exam.decorators, decorator)
            from_root = getattr(exam, decorator)

            expect(from_root).to == from_decorators
예제 #8
0
    def test_it_patches_using_with_plus_arg(self):
        # nothing actually goes to console
        with patch("os.getcwd") as getcwd:
            import os

            getcwd.expects().and_returns("foo")
            expect(os.getcwd()) == "foo"
            self.assertEqual(os.getcwd(), "foo")
예제 #9
0
    def test_it_replaces_dict(self):
        import os

        @patch.dict(os.environ, {"foo": "bar"})
        def it_replaces_dict():
            expect(os.environ) == {"foo": "bar"}
            self.assertEqual(os.environ, {"foo": "bar"})

        it_replaces_dict()
        expect(os.environ) != {"foo": "bar"}
        self.assertNotEqual(os.environ, {"foo": "bar"})
 def test_expect_falsiness(self):
     expect([]).to.be_falsy()
 def test_expect_none(self):
     expect(None).to.be_none()
예제 #12
0
 def test_it_should_generate_new_ids(self):
     msg1 = InvocationMessage()
     msg2 = InvocationMessage()
     expect(msg1.id) != msg2
 def test_expect_truthiness(self):
     expect(1).to.be_truthy()
예제 #14
0
 def test_autodiscover_is_autodiscovery_discover(self):
     from gutter.django.autodiscovery import discover
     expect(autodiscover).to.be_equal_to(discover)
 def test_expect_invocation_raises_exception_class(self):
     def runner():
         raise IndexError()
     expect(runner).with_args().to.raise_error(IndexError)
 def test_expect_float_equality_with_acceptability(self):
     expect(1.0 - 1.0).to.be_close_to(5.0, 10)
 def test_expect_instance_of(self):
     expect(1).to.be_instance_of(int)
 def test_expect_contain(self):
     expect([1, 2, 3]).to.contain(2)
     expect([1, 2, 3]).to.include(1)
 def test_expect_float_equality(self):
     expect(1.0 + 1.0 - 1.0).to.be_close_to(1.0)
예제 #20
0
 def test_arguments_starts_out_empty(self):
     expect(registry.arguments).to == {}
예제 #21
0
    def test_can_register_operators(self):
        new_operators = dict(operator=sentinel.operator)

        expect(registry.operators).to_not.have_subset(new_operators)
        registry.operators.register(sentinel.operator)
        expect(registry.operators).to.have_subset(new_operators)
예제 #22
0
 def test_operators_starts_out_with_default_list(self):
     expect(registry.operators).to == self.default_operator_dict
 def test_expect_inverse(self):
     expect(1).to_not.be_none()
 def test_expect_have_subset(self):
     expect(dict(a=1, b=2, c=3)).to.have_subset(dict(a=1, b=2))
 def test_expect_typeerror_when_assigning_to_not(self):
     with self.assertRaises(SyntaxError):
         expect(1).to_not = 1
 def test_expect_to_be_callable(self):
     expect(dict().keys).to.be_callable()
 def test_expect_subclass_of(self):
     from collections import defaultdict
     expect(defaultdict).to.be_subclass_of(dict)
예제 #28
0
 def test_it_should_hash_passwords(self):
     account = Account.create('jeff', 'password')
     # sha512
     hashed = 'b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86'
     expect(account) == Account('jeff', hashed)
 def test_expect_object_instance_equality(self):
     o = object()
     expect(o).to.be_equal(o)
     expect([1, 2]).to_not.be_equal([1, 2])
 def test_custom_matcher_fails(self):
     try:
         expect([1, 2, 3]).to(be_equal_to_iterable((1, 2, 3, 4)))
     except AssertionError as ae:
         assert ae.message == 'expected [1, 2, 3] to be equal as iterators to (1, 2, 3, 4)'
 def test_expect_raises_assertion_error_when_no_equal_to(self):
     with self.assertRaises(AssertionError):
         expect(1) == 2
 def test_expect_to_assert_less_than_or_equal(self):
     expect(1) <= 1
     expect(1) <= 2
 def test_expect_regular_expression_match(self):
     expect('abcdefff').to.match('f+')
 def test_expect_to_assert_greater_than(self):
     expect(2) > 1
 def test_expect_to_have_attr(self):
     print expect(dict).to
     expect(dict()).to.have_attr('keys')
 def test_expect_to_assert_greater_than_or_equal(self):
     expect(2) >= 2
     expect(2) >= 1
 def test_expect_invocation(self):
     expect(lambda a, b: a + b).with_args(1, 2) == 3
 def test_expect_to_assert_not_equal(self):
     expect(1) != 2
 def test_expect_type_error_when_forgetting_invocation_for_raises_exception(self):
     def runner():
         raise IndexError()
     with self.assertRaises(AssertionError):
         expect(runner).to.raise_error(IndexError)
예제 #40
0
 def test_it_can_be_in_dictionary(self):
     container = {
         Account('user1', 'pwd1'): 1,
     }
     expect(container[Account('user1', 'pwd1')]) == 1