Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It doesn't considered how much time was spent on SetupTestData #19

Open
dzhuang opened this issue Dec 21, 2017 · 2 comments
Open

It doesn't considered how much time was spent on SetupTestData #19

dzhuang opened this issue Dec 21, 2017 · 2 comments

Comments

@dzhuang
Copy link

dzhuang commented Dec 21, 2017

Time spent on SetupTestData is counted into the first test in the testcase. That's not fair to compare.

@SebCorbin
Copy link

Agreed, it would be awesome to extract the time spend on setUpTestData and report it too.
That way it would indicate the need to transform generated data to a fixture for example

@SebCorbin
Copy link

I have modified the TimingSuite to record it

    def run(self, result, debug=False):
        topLevel = False
        if getattr(result, '_testRunEntered', False) is False:
            result._testRunEntered = topLevel = True

        for test in self:
            if result.shouldStop:
                break

            if _isnotsuite(test):
                start_time = _time()
                self._tearDownPreviousClass(test, result)
                self._handleModuleFixture(test, result)
                self._handleClassSetUp(test, result)
                result._previousTestClass = test.__class__

                if (getattr(test.__class__, '_classSetupFailed', False) or
                        getattr(result, '_moduleSetUpFailed', False)):
                    continue
                self.save_test_time(
                    f'{test.__class__.__module__}.{test.__class__.__name__}.setUp '
                    f'({importlib.import_module(test.__class__.__module__).__file__})',
                    _time() - start_time
                )

            start_time = _time()

            if not debug:
                test(result)
            else:
                test.debug()
            self.save_test_time(str(test), _time() - start_time)

        if topLevel:
            self._tearDownPreviousClass(None, result)
            self._handleModuleTearDown(result)
            result._testRunEntered = False

        return result

drewbrew added a commit to drewbrew/django-slow-tests that referenced this issue Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants