Fixed #22531 and added tests for `tree.Node` #2628

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@mmardini
Contributor
mmardini commented May 3, 2014

While Node class has a useful __str__, its __repr__ is not that
useful. Added a __repr__ that makes use of the current __str__.
This is especially useful since the more popular Q class inherits
tree.Node.

@timgraham
Member

A test would be good.

@mmardini
Contributor
mmardini commented May 7, 2014

Thanks Tim for your feedback. After examining the internal tests of Django, I couldn't find a suitable place where a test for this function would really belong. queries/tests.py has tests which use Q objects, but in the context of creating querysets. Would using that file be feasible? Any other recommendation?

@timgraham
Member

I would add a new file: tests/utils_tests/test_tree.py

@timgraham
Member

Can one of the admins verify this patch?

@mmardini mmardini Fixed #22531 and added tests for `tree.Node`
While Node class has a useful `__str__`, its `__repr__` is not that
useful. Added a `__repr__` that makes use of the current `__str__`.
This is especially useful since the more popular `Q` class inherits
`tree.Node`. Also created new tests that cover most of `Node` class
functionality.
c3e5458
@mmardini mmardini changed the title from Fixed #22531 -- Added `__repr__` for `tree.Node` to Fixed #22531 and added tests for `tree.Node` May 16, 2014
@mmardini
Contributor

Added a new tests file. Please verify it too.

@timgraham
Member

Looks good. There were a couple minor flake8 warnings I fixed. merged in 393ddc1.

@timgraham timgraham closed this May 16, 2014
@mmardini
Contributor

Thanks Tim for the review. I will check using flake8 in my future PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment