Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
pekkaklarck committed Jun 11, 2023
1 parent 5ac5781 commit 375afe5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 1 addition & 3 deletions src/robot/model/testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,7 @@ def test_count(self) -> int:

@property
def has_tests(self) -> bool:
if self.tests:
return True
return any(s.has_tests for s in self.suites)
return bool(self.tests) or any(s.has_tests for s in self.suites)

def set_tags(self, add: Sequence[str] = (), remove: Sequence[str] = (),
persist: bool = False):
Expand Down
6 changes: 5 additions & 1 deletion utest/model/test_testsuite.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,19 @@ def test_set_tags_also_to_new_child(self):

def test_all_tests_and_test_count(self):
root = TestSuite()
assert_equal(root.has_tests, False)
assert_equal(root.test_count, 0)
assert_equal(list(root.all_tests), [])
for i in range(10):
suite = root.suites.create()
for j in range(100):
suite.tests.create()
assert_equal(root.has_tests, True)
assert_equal(root.test_count, 1000)
assert_equal(len(list(root.all_tests)), 1000)
assert_equal(list(root.suites[0].all_tests), list(root.suites[0].tests))
for suite in root.suites:
assert_equal(suite.has_tests, True)
assert_equal(list(suite.all_tests), list(suite.tests))

def test_configure_only_works_with_root_suite(self):
for Suite in TestSuite, RunningTestSuite, ResultTestSuite:
Expand Down

0 comments on commit 375afe5

Please sign in to comment.