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

Make compatible with unittest.TestProgram in python3 #167

Merged
merged 2 commits into from
May 18, 2018

Conversation

ikedam
Copy link
Contributor

@ikedam ikedam commented May 15, 2018

Replaces #140.

XMLTestRunner doesn't receive options like -b via unittest.TestProgram in python3.
This is caused for this implementation in unittest in python3: https://github.com/python/cpython/blob/v3.4.8/Lib/unittest/main.py#L234
XMLTestRunner.__init__ should be compatible with TestTestRunner.__init__.

  • Add tests to demonstrate the issue. This will verify that the issue is fixed with this request
  • Fix the issue

* Tests will fail on Python3 as the parameters of XMLTestRunner doesn't suffice required parameters by unitttest.TestProgram.
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.7%) to 96.772% when pulling 5e7f663 on ikedam:feature/compatibleWithTestProgram into a285464 on xmlrunner:master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-2.7%) to 96.772% when pulling 5e7f663 on ikedam:feature/compatibleWithTestProgram into a285464 on xmlrunner:master.

@coveralls
Copy link

coveralls commented May 15, 2018

Coverage Status

Coverage increased (+0.009%) to 99.462% when pulling 04aa9f8 on ikedam:feature/compatibleWithTestProgram into a285464 on xmlrunner:master.

@ikedam
Copy link
Contributor Author

ikedam commented May 15, 2018

test_test_program_fail_with_buffer and test_test_program_succeed_with_buffer failed in python3.3 and python3.4 as reported by TravisCI.
https://travis-ci.org/xmlrunner/unittest-xml-reporting/jobs/379441499
https://travis-ci.org/xmlrunner/unittest-xml-reporting/jobs/379441500

======================================================================
FAIL: test_test_program_fail_with_buffer (tests.testsuite.XMLTestRunnerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/xmlrunner/unittest-xml-reporting/tests/testsuite.py", line 636, in test_test_program_fail_with_buffer
    self.assertNotIn('should be printed', r[0].getvalue())
AssertionError: 'should be printed' unexpectedly found in 'should be printed\n'
======================================================================
FAIL: test_test_program_succeed_with_buffer (tests.testsuite.XMLTestRunnerTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/travis/build/xmlrunner/unittest-xml-reporting/tests/testsuite.py", line 607, in test_test_program_succeed_with_buffer
    self.assertNotIn('should not be printed', r[0].getvalue())
AssertionError: 'should not be printed' unexpectedly found in 'should not be printed\n'

This meant -b option didn't work in python3.
I'll push a commit to fix the issue.

* This ensures `XMLTestRunner.__init__` compatible with `TextTestRunner.__init__`.
@codecov-io
Copy link

Codecov Report

Merging #167 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #167      +/-   ##
==========================================
+ Coverage   99.45%   99.46%   +<.01%     
==========================================
  Files          17       17              
  Lines        1278     1300      +22     
==========================================
+ Hits         1271     1293      +22     
  Misses          7        7
Impacted Files Coverage Δ
xmlrunner/runner.py 100% <100%> (ø) ⬆️
tests/testsuite.py 100% <100%> (ø) ⬆️

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 a285464...04aa9f8. Read the comment docs.

elapsed_times=True, encoding=UTF8,
resultclass=None,
**kwargs):
super(XMLTestRunner, self).__init__(**kwargs)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue is caused for that XMLTestRunner doesn't support warnings parameter that is added to TextTestRunner in python3: https://github.com/python/cpython/blob/v3.4.8/Lib/unittest/runner.py#L129

This change receives any unknown parameters and pass them through to TextTestRunner.
This ensures XMLTestRunner.__init__ is always compatible with TextTestRunner.__init__ and clarifies that XMLTestRunner itself doesn't handle those parameters.

@ikedam ikedam changed the title WIP: Make compatible with unittest.TestProgram in python3 Make compatible with unittest.TestProgram in python3 May 15, 2018
@ikedam ikedam mentioned this pull request May 15, 2018
@dnozay dnozay merged commit 79621f3 into xmlrunner:master May 18, 2018
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

4 participants