Example #1
0
    def test_message_param_not_deprecated(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_subset(set([1, 2]),
                                     set([1, 2, 3]),
                                     message="This is a message")

            assertions.assert_equal(len(w), 0)
Example #2
0
 def _test(self, testname):
     """Regression test for #240."""
     server_process = subprocess.Popen(
         [
             'python',
             '-m',
             'testify.test_program',
             testname,
             '--serve',
             '9001',
             '-v',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     client_1 = subprocess.Popen(
         [
             'python',
             '-m',
             'testify.test_program',
             '--connect',
             'localhost:9001',
             '-v',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     assert_equal(client_1.wait(), 1)
     assert_equal(server_process.wait(), 1)
Example #3
0
    def test_message_param_not_deprecated(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_dict_subset({"a": 1, "b": 2},
                                          {"a": 1, "b": 2, "c": 3},
                                          message="This is a message")

            assertions.assert_equal(len(w), 0)
Example #4
0
    def test_message_param_not_deprecated(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_all_not_match_regex("qux",
                                                  ["foobar", "barbaz"],
                                                  message="This is a message")

            assertions.assert_equal(len(w), 0)
Example #5
0
    def test_deprecated_msg_param(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_is_not(False, None, msg="This is a message")

            assertions.assert_equal(len(w), 1)
            assert issubclass(w[-1].category, DeprecationWarning)
            assertions.assert_in("msg is deprecated", str(w[-1].message))
Example #6
0
    def test_list_tests_json_suites(self):
        output = test_call([
            sys.executable,
            '-m',
            'testify.test_program',
            '--list-tests',
            'test.test_suites_test',
            '--list-tests-format',
            'json',
        ])
        assert_equal(output, '''\
{"suites": ["class-level-suite", "disabled", "example", "module-level"], "test": "test.test_suites_test ListSuitesTestCase.test_also_disabled"}
{"suites": ["class-level-suite", "crazy", "disabled", "example", "module-level"], "test": "test.test_suites_test ListSuitesTestCase.test_disabled"}
{"suites": ["class-level-suite", "example", "module-level"], "test": "test.test_suites_test ListSuitesTestCase.<lambda>"}
{"suites": ["assertion", "class-level-suite", "example", "module-level"], "test": "test.test_suites_test ListSuitesTestCase.test_list_suites"}
{"suites": ["class-level-suite", "example", "module-level"], "test": "test.test_suites_test ListSuitesTestCase.test_not_disabled"}
{"suites": ["class-level-suite", "disabled", "example", "module-level"], "test": "test.test_suites_test TestifiedListSuitesUnittestCase.test_also_disabled"}
{"suites": ["class-level-suite", "crazy", "disabled", "example", "module-level"], "test": "test.test_suites_test TestifiedListSuitesUnittestCase.test_disabled"}
{"suites": ["assertion", "class-level-suite", "example", "module-level"], "test": "test.test_suites_test TestifiedListSuitesUnittestCase.test_list_suites"}
{"suites": ["class-level-suite", "example", "module-level"], "test": "test.test_suites_test TestifiedListSuitesUnittestCase.test_not_disabled"}
{"suites": ["example", "module-level", "sub"], "test": "test.test_suites_test SubDecoratedTestCase.test_thing"}
{"suites": ["example", "module-level", "sub", "super"], "test": "test.test_suites_test SubTestCase.test_thing"}
{"suites": ["example", "module-level", "super"], "test": "test.test_suites_test SuperDecoratedTestCase.test_thing"}
{"suites": ["example", "module-level", "super"], "test": "test.test_suites_test SuperTestCase.test_thing"}
{"suites": ["module-level"], "test": "test.test_suites_test TestSuitesTestCase.test_subclass_suites_doesnt_affect_superclass_suites"}
{"suites": ["module-level"], "test": "test.test_suites_test TestSuitesTestCase.test_suite_decorator_overrides_parent"}'''
                     )  # noqa
Example #7
0
    def test_message_param_not_deprecated(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_subset(set([1, 2]),
                                     set([1, 2, 3]),
                                     message="This is a message")

            assertions.assert_equal(len(w), 0)
Example #8
0
    def test_deprecated_msg_param(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_is_not(False, None, msg="This is a message")

            assertions.assert_equal(len(w), 1)
            assert issubclass(w[-1].category, DeprecationWarning)
            assertions.assert_in("msg is deprecated", str(w[-1].message))
 def test__parse_test_runner_command_line_module_method_overrides_empty_input(
         self):
     """Make sure _parse_test_runner_command_line_module_method_overrides returns something sensible if you pass it an empty list of arguments."""
     assert_equal(
         test_program.
         _parse_test_runner_command_line_module_method_overrides([]),
         (None, {}))
Example #10
0
    def test_deprecated_msg_param(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_all_not_match_regex("qux", ["foobar", "barbaz"],
                                                  msg="This is a message")

            assertions.assert_equal(len(w), 1)
            assert issubclass(w[-1].category, DeprecationWarning)
            assertions.assert_in("msg is deprecated", str(w[-1].message))
Example #11
0
 def test(self):
     super(SimpleTestCase, self).test()
     assert_equal(
         self.lines,
         ['first', '1', 'second', '2.0', 'third', 'asdf', 'fourth', 'ohai',
          'fifth', 'hommage à jack'
         ]
     )
 def test_build_reader(self, mock_get_namespace):
     config_key, validator, namespace = 'the_key', mock.Mock(), 'the_name'
     reader = readers.build_reader(validator, namespace)
     value = reader(config_key)
     mock_get_namespace.assert_called_with(namespace)
     validator.assert_called_with(
         mock_get_namespace.return_value.get.return_value)
     assert_equal(value, validator.return_value)
 def test_build_reader(self, mock_get_namespace):
     config_key, validator, namespace = 'the_key', mock.Mock(), 'the_name'
     reader = readers.build_reader(validator, namespace)
     value = reader(config_key)
     mock_get_namespace.assert_called_with(namespace)
     validator.assert_called_with(
         mock_get_namespace.return_value.get.return_value)
     assert_equal(value, validator.return_value)
Example #14
0
    def test_deprecated_msg_param(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_dict_subset({"a": 1, "b": 2},
                                          {"a": 1, "b": 2, "c": 3},
                                          msg="This is a message")

            assertions.assert_equal(len(w), 1)
            assert issubclass(w[-1].category, DeprecationWarning)
            assertions.assert_in("msg is deprecated", str(w[-1].message))
Example #15
0
    def test_deprecated_msg_param(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_all_not_match_regex("qux",
                                                  ["foobar", "barbaz"],
                                                  msg="This is a message")

            assertions.assert_equal(len(w), 1)
            assert issubclass(w[-1].category, DeprecationWarning)
            assertions.assert_in("msg is deprecated", str(w[-1].message))
Example #16
0
    def test(self):
        super(TestCase, self).test()

        expected_lines = ['self.bar %s' % (BAR_VALUE,),
                'self.counter 0',
                'self.bar still %s' % (BAR_VALUE,),
                'self.counter now 1',
                'asdf asdf']
        assert_equal(self.lines, expected_lines)
Example #17
0
 def test_start(self):
     self.callback.delayed_call.active.return_value = False
     with mock.patch('tron.eventloop.call_later',
                     autospec=True) as mock_call_later:
         self.callback.start()
         mock_call_later.assert_called_with(self.callback.delay,
                                            self.callback.func)
         assert_equal(self.callback.delayed_call,
                      mock_call_later.return_value)
Example #18
0
    def test_can_hash(self):
        # Only immutable objects are hashable, and hashable objects can be dict keys.
        fd1 = fdict(a=1, b=2)
        fd2 = fdict({'a':1, 'b':2})

        mydict = {fd1:1}
        mydict[fd2] = 2

        T.assert_equal(mydict[fd1], 2)
Example #19
0
    def test(self):
        super(SubclassTestCase, self).test()

        assert_equal(self.lines,
                ['simple_subclass::first',
                 'simple_subclass::second',
                 # test that we dispatched correctly to the superclass method
                 'simple_superclass::second',
                ])
Example #20
0
    def test_list_tests_json(self):
        output = test_call([
            sys.executable, '-m', 'testify.test_program',
            '--list-tests', 'testing_suite',
            '--list-tests-format', 'json',
        ])
        assert_equal(output, '''\
{"suites": [], "test": "testing_suite.example_test ExampleTestCase.test_one"}
{"suites": [], "test": "testing_suite.example_test ExampleTestCase.test_two"}
{"suites": [], "test": "testing_suite.example_test SecondTestCase.test_one"}''')
Example #21
0
 def test_client_returns_zero_on_success(self):
     server_process = subprocess.Popen(
         ["python", "-m", "testify.test_program", "testing_suite.example_test", "--serve", "9001"],
         stdout=open(os.devnull, "w"),
         stderr=open(os.devnull, "w"),
     )
     # test_call has the side-effect of asserting the return code is 0
     ret = test_call(["python", "-m", "testify.test_program", "--connect", "localhost:9001"])
     assert_in("PASSED", ret)
     assert_equal(server_process.wait(), 0)
Example #22
0
    def test(self):
        super(TestCase, self).test()

        assert_equal(self.lines, [
            "I'm OK",
            "I'm OK",
            "The alphabet begins with a b c d e",
            "The interpolant is interpolated",
            "I'm OK still",
            "Success!",
        ])
Example #23
0
    def test(self):
        super(TestCase, self).test()

        expected_lines = [
                ''.join(' %d' % (num,) for num in xrange(10)),
                '0 a',
                '1 b',
                '2 c',
        ]

        assert_equal(self.lines, expected_lines)
Example #24
0
    def test_message_param_not_deprecated(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_dicts_equal({
                "a": 1,
                "b": 2
            }, {
                "a": 1,
                "b": 2
            },
                                          message="This is a message")

            assertions.assert_equal(len(w), 0)
Example #25
0
 def test(self):
     super(SimpleTestCase, self).test()
     # sanity check: Python correctly decoded the UTF-8 characters in this file:
     assert_equal(display['fifth'], u'hommage \xe0 jack')
     # note that 'asdf' == u'asdf', so we don't need to explicitly prefix the
     # literals here with u:
     assert_equal(
         self.lines,
         ['first', '1', 'second', '2.0', 'third', 'asdf', 'fourth', 'ohaiunicode',
          'fifth', u'hommage \xe0 jack'
         ]
     )
Example #26
0
    def test(self):
        """Default smoke test; ensure that setup runs, which ensures that compilation and templating will succeed
        without throwing exceptions.
        """
        self.expected_reference_counts = self.get_reference_counts()
        self.run_templating()

        self.expected_result = self.result
        for _ in xrange(self.num_stress_test_iterations):
            self.run_templating(quiet=True)
            # check that the result hasn't changed:
            assert_equal(self.result, self.expected_result)
            assert_equal(self.get_reference_counts(), self.expected_reference_counts)
Example #27
0
    def test(self):
        super(TestCase, self).test()

        expected_lines = [
                'respond: quux',
                'my_func: bar',
                'os.__file__: %s' % (os.__file__,),
                'again: %s' % (os.__file__,),
                'respond_reassignment: bat',
                'in_pipes: |bat|',
                DEFAULT_ARGUMENT,
                'this is the second call to my_func',
        ]
        assert_equal(self.lines, expected_lines)
Example #28
0
    def test_deprecated_msg_param(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_dict_subset({
                "a": 1,
                "b": 2
            }, {
                "a": 1,
                "b": 2,
                "c": 3
            },
                                          msg="This is a message")

            assertions.assert_equal(len(w), 1)
            assert issubclass(w[-1].category, DeprecationWarning)
            assertions.assert_in("msg is deprecated", str(w[-1].message))
Example #29
0
    def test_repr(self):
        fd1 = fdict(a=1, b=2)
        T.assert_equal(repr(fd1), "fdict({'a': 1, 'b': 2})")
        T.assert_equal(eval(repr(fd1)), fd1)

        fd2 = fdict(c=3, **fd1)
        T.assert_equal(repr(fd2), "fdict({'a': 1, 'c': 3, 'b': 2})")
        T.assert_equal(eval(repr(fd2)), fd2)
Example #30
0
    def perform_exception_test(self, exc_class):
        self.expected_reference_counts = self.get_reference_counts()
        for _ in xrange(self.num_stress_test_iterations + 1):
            # there's a fun wrinkle here. we have to make sure the raised exception
            # is completely out of scope and destroyed before we check the reference
            # counts again; otherwise it may hold incidental references to objects,
            # which will appear to the reference count checks here as though it were
            # a memory leak. not that this, you know, actually happened to me or anything.
            assert_raises(exc_class, self.run_templating)
            assert_equal(self.get_reference_counts(), self.expected_reference_counts)

        try:
            self.run_templating()
        except exc_class, e:
            # now that we're done counting references, save the exception for examination:
            self.exception = e
Example #31
0
    def test_list_tests_json(self):
        output = test_call([
            sys.executable,
            '-m',
            'testify.test_program',
            '--list-tests',
            'testing_suite',
            '--list-tests-format',
            'json',
        ])
        assert_equal(
            output, '''\
{"suites": [], "test": "testing_suite.example_test ExampleTestCase.test_one"}
{"suites": [], "test": "testing_suite.example_test ExampleTestCase.test_two"}
{"suites": [], "test": "testing_suite.example_test SecondTestCase.test_one"}'''
        )
Example #32
0
 def test_client_returns_zero_on_success(self):
     server_process = subprocess.Popen(
         [
             'python', '-m', 'testify.test_program',
             'testing_suite.example_test',
             '--serve', '9001',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     # test_call has the side-effect of asserting the return code is 0
     ret = test_call([
         'python', '-m', 'testify.test_program',
         '--connect', 'localhost:9001',
     ])
     assert_in('PASSED', ret)
     assert_equal(server_process.wait(), 0)
Example #33
0
 def test_client_returns_zero_on_success(self):
     server_process = subprocess.Popen(
         [
             'python', '-m', 'testify.test_program',
             'testing_suite.example_test',
             '--serve', '9001',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     # test_call has the side-effect of asserting the return code is 0
     ret = test_call([
         'python', '-m', 'testify.test_program',
         '--connect', 'localhost:9001',
     ])
     assert_in('PASSED', ret)
     assert_equal(server_process.wait(), 0)
Example #34
0
    def assert_rerun_discovery(self, format):
        output = test_call([
            'sh', '-c', '''\
{python} -m testify.test_program --list-tests test.test_suites_test --list-tests-format {format} |
{python} -m testify.test_program -v --require-suite example --exclude-suite disabled --exclude-suite assertion --rerun-test-file -
'''.format(python=sys.executable, format=format)
        ])
        output = re.sub(r'\b[0-9.]+s\b', '${TIME}', output)
        assert_equal(output, '''\
test.test_suites_test ListSuitesTestCase.<lambda> ... ok in ${TIME}
test.test_suites_test ListSuitesTestCase.test_not_disabled ... ok in ${TIME}
test.test_suites_test TestifiedListSuitesUnittestCase.test_not_disabled ... ok in ${TIME}
test.test_suites_test SubDecoratedTestCase.test_thing ... ok in ${TIME}
test.test_suites_test SubTestCase.test_thing ... ok in ${TIME}
test.test_suites_test SuperDecoratedTestCase.test_thing ... ok in ${TIME}
test.test_suites_test SuperTestCase.test_thing ... ok in ${TIME}

PASSED.  7 tests / 6 cases: 7 passed, 0 failed.  (Total test time ${TIME})''')
Example #35
0
    def test(self):
        super(TestCase, self).test()

        modules = [
            "bisect",
            "os",
            "os",
            "os.path",
            "email.utils",
            "email.errors",
            "email.mime.image",
            "email.mime.image",
            "email",
            "email.charset",
            "xml.dom.minidom",
        ]
        files = [sys.modules[module].__file__ for module in modules]
        assert_equal(self.lines, files)
Example #36
0
    def test_cheap_hash(self):
        import mock
        import __builtin__
        with mock.patch.object(__builtin__, 'hash', wraps=hash) as mock_hash:
            fd = fdict(a=1)

            T.assert_equal((('a', 1),).__hash__(), fd.__hash__())
            T.assert_equal(1, mock_hash.call_count)

            T.assert_equal((('a', 1),).__hash__(), fd.__hash__())
            T.assert_equal(1, mock_hash.call_count)
Example #37
0
    def run_templating(self, quiet=False):
        """Run the display dict against self.responder, get the output, measure the elapsed time."""
        display = self.get_display()
        self_ptr = self.self_ptr
        responder = self.responder

        self.result = result = None
        start_time = time.time()
        result = responder(display, self_ptr)
        self.elapsed_time = time.time() - start_time
        self.result = result

        assert_equal(type(result), self.expected_result_type)

        if self.verbose and not quiet:
            print self.result

        if not quiet:
            print >>sys.stderr, "Elapsed time in milliseconds: %f" % (self.elapsed_time * 1000.0)
Example #38
0
    def assert_rerun_discovery(self, format):
        output = test_call([
            'sh', '-c', '''\
{python} -m testify.test_program --list-tests test.test_suites_test --list-tests-format {format} |
{python} -m testify.test_program -v --require-suite example --exclude-suite disabled --exclude-suite assertion --rerun-test-file -
'''.format(python=sys.executable, format=format)
        ])
        output = re.sub(r'\b[0-9.]+s\b', '${TIME}', output)
        assert_equal(
            output, '''\
test.test_suites_test ListSuitesTestCase.<lambda> ... ok in ${TIME}
test.test_suites_test ListSuitesTestCase.test_not_disabled ... ok in ${TIME}
test.test_suites_test TestifiedListSuitesUnittestCase.test_not_disabled ... ok in ${TIME}
test.test_suites_test SubDecoratedTestCase.test_thing ... ok in ${TIME}
test.test_suites_test SubTestCase.test_thing ... ok in ${TIME}
test.test_suites_test SuperDecoratedTestCase.test_thing ... ok in ${TIME}
test.test_suites_test SuperTestCase.test_thing ... ok in ${TIME}

PASSED.  7 tests / 6 cases: 7 passed, 0 failed.  (Total test time ${TIME})''')
Example #39
0
 def test_client_returns_nonzero_on_failure(self):
     server_process = subprocess.Popen(
         [
             'python', '-m', 'testify.test_program',
             'test.failing_test',
             '--serve', '9001',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     # Need two clients in order to finish running tests
     client_1 = subprocess.Popen(
         [
             'python', '-m', 'testify.test_program',
             '--connect', 'localhost:9001',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     client_2 = subprocess.Popen(
         [
             'python', '-m', 'testify.test_program',
             '--connect', 'localhost:9001',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     assert_equal(client_1.wait(), 1)
     assert_equal(client_2.wait(), 1)
     assert_equal(server_process.wait(), 1)
Example #40
0
    def test_list_tests_json_suites(self):
        output = test_call([
            sys.executable, '-m', 'testify.test_program',
            '--list-tests', 'test.test_suites_test',
            '--list-tests-format', 'json',
        ])
        assert_equal(output, '''\
{"suites": ["class-level-suite", "disabled", "example", "module-level"], "test": "test.test_suites_test ListSuitesTestCase.test_also_disabled"}
{"suites": ["class-level-suite", "crazy", "disabled", "example", "module-level"], "test": "test.test_suites_test ListSuitesTestCase.test_disabled"}
{"suites": ["class-level-suite", "example", "module-level"], "test": "test.test_suites_test ListSuitesTestCase.<lambda>"}
{"suites": ["assertion", "class-level-suite", "example", "module-level"], "test": "test.test_suites_test ListSuitesTestCase.test_list_suites"}
{"suites": ["class-level-suite", "example", "module-level"], "test": "test.test_suites_test ListSuitesTestCase.test_not_disabled"}
{"suites": ["class-level-suite", "disabled", "example", "module-level"], "test": "test.test_suites_test TestifiedListSuitesUnittestCase.test_also_disabled"}
{"suites": ["class-level-suite", "crazy", "disabled", "example", "module-level"], "test": "test.test_suites_test TestifiedListSuitesUnittestCase.test_disabled"}
{"suites": ["assertion", "class-level-suite", "example", "module-level"], "test": "test.test_suites_test TestifiedListSuitesUnittestCase.test_list_suites"}
{"suites": ["class-level-suite", "example", "module-level"], "test": "test.test_suites_test TestifiedListSuitesUnittestCase.test_not_disabled"}
{"suites": ["example", "module-level", "sub"], "test": "test.test_suites_test SubDecoratedTestCase.test_thing"}
{"suites": ["example", "module-level", "sub", "super"], "test": "test.test_suites_test SubTestCase.test_thing"}
{"suites": ["example", "module-level", "super"], "test": "test.test_suites_test SuperDecoratedTestCase.test_thing"}
{"suites": ["example", "module-level", "super"], "test": "test.test_suites_test SuperTestCase.test_thing"}
{"suites": ["module-level"], "test": "test.test_suites_test TestSuitesTestCase.test_subclass_suites_doesnt_affect_superclass_suites"}
{"suites": ["module-level"], "test": "test.test_suites_test TestSuitesTestCase.test_suite_decorator_overrides_parent"}''')  # noqa
Example #41
0
    def test(self):
        super(TestCase, self).test()

        expected_lines = [
                'begin first test',
                'a b',
                'c d',
                'end first test',
                'begin second test',
                'x z',
                'b d',
                'end second test',
                'begin third test',
                bar,
                'i j',
                'k l',
                'end third test',
                'begin fourth test',
                'u v',
                'end fourth test',
        ]

        assert_equal(self.lines, expected_lines)
Example #42
0
 def _test(self, testname):
     """Regression test for #240."""
     server_process = subprocess.Popen(
         [
             'python', '-m', 'testify.test_program',
             testname,
             '--serve', '9001',
             '-v',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     client_1 = subprocess.Popen(
         [
             'python', '-m', 'testify.test_program',
             '--connect', 'localhost:9001',
             '-v',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     assert_equal(client_1.wait(), 1)
     assert_equal(server_process.wait(), 1)
Example #43
0
 def test_client_returns_nonzero_on_failure(self):
     server_process = subprocess.Popen(
         ["python", "-m", "testify.test_program", "test.failing_test", "--serve", "9001"],
         stdout=open(os.devnull, "w"),
         stderr=open(os.devnull, "w"),
     )
     # Need two clients in order to finish running tests
     client_1 = subprocess.Popen(
         ["python", "-m", "testify.test_program", "--connect", "localhost:9001"],
         stdout=open(os.devnull, "w"),
         stderr=open(os.devnull, "w"),
     )
     client_2 = subprocess.Popen(
         ["python", "-m", "testify.test_program", "--connect", "localhost:9001"],
         stdout=open(os.devnull, "w"),
         stderr=open(os.devnull, "w"),
     )
     assert_equal(client_1.wait(), 1)
     assert_equal(client_2.wait(), 1)
     assert_equal(server_process.wait(), 1)
Example #44
0
 def test_client_returns_nonzero_on_failure(self):
     server_process = subprocess.Popen(
         [
             'python',
             '-m',
             'testify.test_program',
             'test.failing_test',
             '--serve',
             '9001',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     # Need two clients in order to finish running tests
     client_1 = subprocess.Popen(
         [
             'python',
             '-m',
             'testify.test_program',
             '--connect',
             'localhost:9001',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     client_2 = subprocess.Popen(
         [
             'python',
             '-m',
             'testify.test_program',
             '--connect',
             'localhost:9001',
         ],
         stdout=open(os.devnull, 'w'),
         stderr=open(os.devnull, 'w'),
     )
     assert_equal(client_1.wait(), 1)
     assert_equal(client_2.wait(), 1)
     assert_equal(server_process.wait(), 1)
Example #45
0
 def test_run_testify_as_module_list_tests(self):
     output = test_call([
         sys.executable, '-m', 'testify.test_program', '--list-tests',
         'testing_suite'
     ])
     assert_equal(output, self.expected_list)
Example #46
0
 def test_run_testify_from_bin_list_tests(self):
     output = test_call(['bin/testify', '--list-tests', 'testing_suite'])
     assert_equal(output, self.expected_list)
Example #47
0
 def test__iter__(self):
     assert_equal(set(self.enum), set(self.values))
Example #48
0
    def test_message_param_not_deprecated(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_is_not(False, None, message="This is a message")

            assertions.assert_equal(len(w), 0)
Example #49
0
 def test_create(self):
     assert_equal(self.enum.values, set(self.values))
Example #50
0
 def assert_with_unicode_msg():
     assertions.assert_equal(unicode_string, utf8_string)
Example #51
0
 def message_has_whole_iterable_sample(exception):
     assertions.assert_equal(str(exception), expected_message)
Example #52
0
 def message_has_no_sample(exception):
     assertions.assert_equal(str(exception), expected_message)
Example #53
0
    def test_len(self):
        fd1 = fdict(a=1, b=2)
        T.assert_equal(len(fd1), 2)

        fd2 = fdict(c=3, **fd1)
        T.assert_equal(len(fd2), 3)
Example #54
0
    def test_is_immutable(self):
        fd = fdict(a=1)
        T.assert_equal(fd['a'], 1)

        with T.assert_raises(TypeError):
            fd['a'] = 2
Example #55
0
 def test_contains_item_not_equal(self):
     mock_item, mock_func = mock.Mock(), mock.Mock()
     self.collection[mock_item.get_name()] = 'other item'
     result = self.collection.contains_item(mock_item, mock_func)
     assert_equal(result, mock_func.return_value)
     mock_func.assert_called_with(mock_item)
Example #56
0
 def test__init__(self):
     assert_equal(self.callback.delay, 5)
     assert_equal(self.callback.func, self.func)
Example #57
0
    def test_message_param_not_deprecated(self):
        with warnings.catch_warnings(record=True) as w:
            assertions.assert_all_not_match_regex("qux", ["foobar", "barbaz"],
                                                  message="This is a message")

            assertions.assert_equal(len(w), 0)