예제 #1
0
    def test_diff(self):
        with pretend_not_under_pytest():
            with record(record_name="test_diff"):
                caches["default"].get("foo")

            with pytest.raises(AssertionError) as excinfo:
                with record(record_name="test_diff"):
                    caches["default"].get("bar")

            msg = str(excinfo.value)
            assert "- cache|get: foo\n" in msg
            assert "+ cache|get: bar\n" in msg
예제 #2
0
    def test_single_cache_op_with_traceback(self):
        with pretend_not_under_pytest():
            with pytest.raises(AssertionError) as excinfo:

                def capture_traceback(operation):
                    return True

                with record(
                        record_name="RecordTests.test_single_cache_op",
                        capture_traceback=capture_traceback,
                ):
                    caches["default"].get("foo")

            msg = str(excinfo.value)
            assert "+ traceback:" in msg
            assert "in test_single_cache_op_with_traceback" in msg
예제 #3
0
    def test_single_db_query_with_traceback(self):
        with pretend_not_under_pytest():
            with pytest.raises(AssertionError) as excinfo:

                def capture_traceback(operation):
                    return True

                with record(
                        record_name="RecordTests.test_single_db_query",
                        capture_traceback=capture_traceback,
                ):
                    run_query("default", "SELECT 1337")

            msg = str(excinfo.value)
            assert (
                "Performance record did not match for RecordTests.test_single_db_query"
                in msg)
            assert "+ traceback:" in msg
            assert "in test_single_db_query_with_traceback" in msg
예제 #4
0
 def test_in_pytest_pretend(self):
     # The test helper should work to ignore it
     with pretend_not_under_pytest():
         assert not pytest_plugin.in_pytest