Skip to content

Conversation

XonqNopp
Copy link
Contributor

@XonqNopp XonqNopp commented Mar 9, 2020

Close #219

@coveralls
Copy link

coveralls commented Mar 9, 2020

Coverage Status

Coverage increased (+0.005%) to 99.603% when pulling 2512b43 on XonqNopp:219_subtest_with_object_breaks_XML_generation into 7723be8 on xmlrunner:master.

@XonqNopp XonqNopp force-pushed the 219_subtest_with_object_breaks_XML_generation branch 2 times, most recently from 385fec7 to ed4666c Compare March 9, 2020 07:43
@danielfm
Copy link
Contributor

danielfm commented Mar 9, 2020

Codecov Report

Merging #220 into master will increase coverage by 5.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #220      +/-   ##
==========================================
+ Coverage   94.48%   99.54%   +5.05%     
==========================================
  Files          15       15              
  Lines        1523     1525       +2     
==========================================
+ Hits         1439     1518      +79     
+ Misses         84        7      -77     
Impacted Files Coverage Δ
xmlrunner/result.py 98.59% <100.00%> (+0.85%) ⬆️
tests/django_example/app/tests.py 100.00% <0.00%> (ø)
tests/django_example/app2/tests.py 100.00% <0.00%> (ø)
xmlrunner/extra/djangotestrunner.py 96.77% <0.00%> (ø)
tests/django_test.py 100.00% <0.00%> (+74.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e8a337c...ed4666c. Read the comment docs.

1 similar comment
@codecov-io
Copy link

codecov-io commented Mar 9, 2020

Codecov Report

Merging #220 into master will increase coverage by 5.05%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #220      +/-   ##
==========================================
+ Coverage   94.48%   99.54%   +5.05%     
==========================================
  Files          15       15              
  Lines        1523     1525       +2     
==========================================
+ Hits         1439     1518      +79     
+ Misses         84        7      -77     
Impacted Files Coverage Δ
xmlrunner/result.py 98.59% <100.00%> (+0.85%) ⬆️
tests/django_example/app/tests.py 100.00% <0.00%> (ø)
tests/django_example/app2/tests.py 100.00% <0.00%> (ø)
xmlrunner/extra/djangotestrunner.py 96.77% <0.00%> (ø)
tests/django_test.py 100.00% <0.00%> (+74.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e8a337c...ed4666c. Read the comment docs.

@XonqNopp
Copy link
Contributor Author

Actually it should also fix when there are floats in the subtest

@XonqNopp
Copy link
Contributor Author

@dnozay did I do something wrong?

@dnozay
Copy link
Member

dnozay commented Apr 16, 2020

@XonqNopp - it would be good to have a unit test that demonstrates / exercises the incorrect behavior.

@XonqNopp XonqNopp force-pushed the 219_subtest_with_object_breaks_XML_generation branch 4 times, most recently from 4488d42 to e6cf584 Compare April 17, 2020 08:54
@XonqNopp
Copy link
Contributor Author

I added tests and tried them: before the fix, the build failed https://travis-ci.org/github/xmlrunner/unittest-xml-reporting/builds/676106789

With the fix it is now passing https://travis-ci.org/github/xmlrunner/unittest-xml-reporting/builds/676107976

However, the pytest step failed. And I must admit that I cannot understand what is wrong after reading the log for 15min. Can you please give me a hint as to what I should fix?

@XonqNopp
Copy link
Contributor Author

@dnozay any help to understand how to fix the test would be appreciated ;-)

@dnozay
Copy link
Member

dnozay commented May 1, 2020

__________________ TestCaseSubclassWithNoSuper.test_something __________________
cls = <class '_pytest.runner.CallInfo'>
func = <function call_runtest_hook.<locals>.<lambda> at 0x7f208078a550>
when = 'call'
reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)
    @classmethod
    def from_call(cls, func, when, reraise=None) -> "CallInfo":
        #: context of invocation: one of "setup", "call",
        #: "teardown", "memocollect"
        start = time()
        excinfo = None
        try:
>           result = func()
.tox/pytest/lib/python3.8/site-packages/_pytest/runner.py:244: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
.tox/pytest/lib/python3.8/site-packages/_pytest/runner.py:217: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
.tox/pytest/lib/python3.8/site-packages/pluggy/hooks.py:286: in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
.tox/pytest/lib/python3.8/site-packages/pluggy/manager.py:93: in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
.tox/pytest/lib/python3.8/site-packages/pluggy/manager.py:84: in <lambda>
    self._inner_hookexec = lambda hook, methods, kwargs: hook.multicall(
.tox/pytest/lib/python3.8/site-packages/_pytest/runner.py:143: in pytest_runtest_call
    raise e
.tox/pytest/lib/python3.8/site-packages/_pytest/runner.py:135: in pytest_runtest_call
    item.runtest()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
self = <TestCaseFunction test_something>
    def runtest(self):
        # TODO: move testcase reporter into separate class, this shouldnt be on item
        import unittest
    
>       testMethod = getattr(self._testcase, self._testcase._testMethodName)
E       AttributeError: 'TestCaseSubclassWithNoSuper' object has no attribute '_testMethodName'
.tox/pytest/lib/python3.8/site-packages/_pytest/unittest.py:210: AttributeError

I think this is an issue on pytest for not practicing defensive coding.
https://github.com/pytest-dev/pytest/blob/92767fec5122a14fbf671374c9162e947278339b/src/_pytest/unittest.py#L206-L210

this seems similar to #189

@dnozay
Copy link
Member

dnozay commented May 1, 2020

https://github.com/python/cpython/blob/3.8/Lib/unittest/case.py#L375-L407

     If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.

gonna have to remove the broken test TestCaseSubclassWithNoSuper

dnozay added a commit that referenced this pull request May 1, 2020
remove broken test, see #220 and #189 

```
    If it is necessary to override the __init__ method, the base class
    __init__ method must always be called. It is important that subclasses
    should not change the signature of their __init__ method, since instances
    of the classes are instantiated automatically by parts of the framework
    in order to be run.
```
@dnozay
Copy link
Member

dnozay commented May 1, 2020

@XonqNopp - can you please rebase and try again? I'll merge if CI passes.

@XonqNopp XonqNopp force-pushed the 219_subtest_with_object_breaks_XML_generation branch from 450b461 to 2512b43 Compare May 4, 2020 04:34
@XonqNopp
Copy link
Contributor Author

XonqNopp commented May 4, 2020

@dnozay all tests passed :-)

@dnozay dnozay merged commit aaa2d37 into xmlrunner:master May 7, 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

Successfully merging this pull request may close these issues.

subtest with object breaks XML generation
5 participants