Skip to content

Commit

Permalink
Fix issue #59 (#60)
Browse files Browse the repository at this point in the history
* Organizing the gitignore

* there is port to python 3

* fix #59 : .join wait the current thread finish

* rm time lib

* Test unittest coverage issue #59
  • Loading branch information
Dayof authored and therealphildini committed May 24, 2017
1 parent fb4d260 commit e5456b7
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 9 deletions.
21 changes: 15 additions & 6 deletions .gitignore
@@ -1,10 +1,19 @@
# Byte-compiled
*.pyc
*~
.*.sw[op]

# Tests
.coverage
.tox

# Distribution
env/
dist/
build/
*.egg-info
dist
build
_build
distribute-*
.coverage
.tox

# Others
.DS_Store
.*.sw[op]
*~
2 changes: 2 additions & 0 deletions cricket/executor.py
Expand Up @@ -46,11 +46,13 @@ def __init__(self, project, count, labels):
t = Thread(target=enqueue_output, args=(self.proc.stdout, self.stdout))
t.daemon = True
t.start()
t.join()

self.stderr = Queue()
t = Thread(target=enqueue_output, args=(self.proc.stderr, self.stderr))
t.daemon = True
t.start()
t.join()

# The TestMethod object currently under execution.
self.current_test = None
Expand Down
2 changes: 0 additions & 2 deletions docs/internals/roadmap.rst
Expand Up @@ -7,8 +7,6 @@ you'd like to contribute, providing a patch for one of these features:
* Use a standard protocol (e.g., subunit) for communicating between the
executor and the GUI

* Port to Python 3

* Add a pytest backend

* Add a nose backend
Expand Down
48 changes: 47 additions & 1 deletion tests/test_unit_integration.py
Expand Up @@ -5,6 +5,52 @@

from cricket.unittest import discoverer
from cricket.unittest import executor
from cricket.unittest.model import UnittestProject
from cricket.executor import Executor
from cricket.model import TestMethod

class TestTestsCoverage(unittest.TestCase):

def setUp(self):
super(TestTestsCoverage, self).setUp()
self.project = UnittestProject()
self.project.refresh([
'tests.test_unit_integration.TestCollection.test_testCollection',
'tests.test_unit_integration.TestExecutorCmdLine.test_labels',
'tests.test_unit_integration.TestTestsCoverage.test_run_methods_tests_in_different_tests_cases',
'tests.test_unit_integration.TestStubToTestCoverage.test_stub1',
'tests.test_unit_integration.TestStubToTestCoverage.test_stub2',
'tests.test_unit_integration.TestStubToTestCoverage.test_stub3',
])

self.labels = [
'tests.test_unit_integration.TestCollection.test_testCollection',
'tests.test_unit_integration.TestStubToTestCoverage.test_stub1',
'tests.test_unit_integration.TestStubToTestCoverage.test_stub2',
'tests.test_unit_integration.TestStubToTestCoverage.test_stub3',
]

def test_run_methods_tests_in_different_tests_cases(self):
'''
Test coverage in a test module, selecting test methods from different tests cases (but not all tests cases from a test module)
'''

count, new_labels = self.project.find_tests(True, None, self.labels)
self.executor = Executor(self.project, count, new_labels)
self.executor.poll()
self.assertEquals(
self.executor.result_count.get(TestMethod.STATUS_PASS, 0), 4)

class TestStubToTestCoverage(unittest.TestCase):

def test_stub1(self):
self.assertTrue(True)

def test_stub2(self):
self.assertTrue(True)

def test_stub3(self):
self.assertTrue(True)

class TestCollection(unittest.TestCase):

Expand Down Expand Up @@ -79,4 +125,4 @@ def test_labels(self):
# PTE.stream_results()

if __name__ == '__main__':
unittest.main()
unittest.main()

0 comments on commit e5456b7

Please sign in to comment.