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

Create assert_that function and use it from TestCase.assertThat. #70

Merged
merged 5 commits into from
Jun 10, 2014

Conversation

OddBloke
Copy link
Contributor

This will allow matchers to be used outside of the TestCase context. This is useful for people who can't buy in to testtools.TestCase fully (for whatever reason), or who like using function/generator tests (as supported by nose).

This isn't a full patch (and so shouldn't be merged as-is), but I wanted to get feedback on whether this approach would be acceptable before doing anything else.

Assuming it is acceptable, thoughts on how best to test it would be appreciated. My initial instinct was to modify all of the tests exercising the core behaviour I've extracted to point at assert_that and write some new tests to ensure that assertThat consumes the assert_that API correctly.

However, as we will be exposing essentially the same API in two places (assert_that and self.assertThat), I wonder if we should run the core-behaviour tests against both places by parameterising them somehow, so we're fully testing our public API. Thoughts appreciated.

This will fix https://bugs.launchpad.net/testtools/+bug/1243834 (by providing the global function mentioned in the title).

This will allow matchers to be used outside of the TestCase context.
This is useful for people who can't buy in to testtools.TestCase fully
(for whatever reason), or who like using function tests (as supported by
nose).
@OddBloke
Copy link
Contributor Author

OddBloke commented Dec 4, 2013

Both @jml and @rbtcollins have indicated it's something that they'd be interested in, so I've updated the assertThat tests to be parameterised for both assert_that and assertThat, added some docs and a NEWS entry.

@rbtcollins
Copy link
Member

I'm about to review the code; could you collapse this down to a series of semantic patches (vs an arc of exploration) after that? Thanks!

------------

* Introduce the assert_that function, which allows matchers to be used
independent of testtools.TestCase. (Daniel Watkins, #1243834)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like an exaggeration: Matchers are already independent of TestCase; what this specifically does is provides a function based assert that uses Matchers.

@rbtcollins
Copy link
Member

Oh, and the move of tests is super hard to reason about; one way to make that easier might be to separate out the move-to-new-file and break-into-new-class steps.

@jml jml merged commit 57a25b9 into testing-cabal:master Jun 10, 2014
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

Successfully merging this pull request may close these issues.

None yet

3 participants