Skip to content

Added test suite attributes #42

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

Merged
merged 4 commits into from
Apr 11, 2017

Conversation

@sysradium
Copy link
Collaborator

I guess you should only append the arguments in the __init__ signature not to break anyones code.

New attributes do not break old code
@wchmb
Copy link
Contributor Author

wchmb commented Apr 10, 2017

Hi! I made the changes you proposed for backward compatibility. Is it ok now?

def __init__(self, name, assertions=None, elapsed_sec=None,
timestamp=None, classname=None, status=None, category=None, file=None, line=None,
log=None, group=None, url=None, stdout=None, stderr=None):
def __init__(self, name, classname=None, elapsed_sec=None, stdout=None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here you have also changed the signtature

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed back the signature as it was in #38 before my #41 (where I broke the signature)
def __init__(self, name, classname=None, elapsed_sec=None, stdout=None, stderr=None):

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK, sorry.

@@ -308,6 +336,7 @@ def __init__(self, name, assertions=None, elapsed_sec=None,
self.stdout = stdout
self.stderr = stderr

self.enable = True
Copy link
Collaborator

Choose a reason for hiding this comment

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

It seems that it is better to call it is_enabled

@@ -317,6 +346,10 @@ def __init__(self, name, assertions=None, elapsed_sec=None,
self.skipped_message = None
self.skipped_output = None

def disable(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

It is not java, so it is not necessary to add setters/getters. If in the future you'd need to add some logic you can easily do that converting is_enabled to a property. So I would drop that if that's was your concern

@@ -342,6 +375,10 @@ def add_skipped_info(self, message=None, output=None):
if output:
self.skipped_output = output

def is_disabled(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same here, I would drop that in favour of just using is_enabled flag.

@@ -73,8 +73,8 @@ def test_single_suite_no_test_cases(self):

(ts, tcs) = serialize_and_read(
TestSuite(
'test',
[],
name='test',
Copy link
Collaborator

Choose a reason for hiding this comment

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

As you can see after you changed the constructors signature you broke the tests already. That could be someones code :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here, I just add attributes explicitly in constructor signature. I think I don't break anyone's code :___(

Copy link
Collaborator

@sysradium sysradium Apr 11, 2017

Choose a reason for hiding this comment

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

Off course not. My comment was about this: imagine you have a function and a test:

def foo(a, b, c): ...

def test_foo():
     foo('1', '2', [])

If you change the signature of foo to foo(a, c, b) you break the client code and the test as well. And I thought that you realised and fixed that problem just modifying the test:

def test_foo():
     foo(a='1', b='2', c=[])

So the test now works but still there are guys out there whose code broke :) So the failing test was a red flag here. If you did not - then it's fine.

# test cases
for case in self.test_cases:
test_case_attributes = dict()
test_case_attributes['name'] = decode(case.name, encoding)
if case.assertions:
test_case_attributes['assertions'] = decode(case.assertions, encoding)
test_case_attributes['assertions'] = "%d" % case.assertions
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you comment that change?

Added explanatory comment about 'assertions' attribute
@@ -213,7 +213,7 @@ def test_attribute_time(self):

def test_attribute_disable(self):
tc = TestCase('Disabled-Test')
tc.disable()
tc.is_enabled=False
Copy link
Collaborator

Choose a reason for hiding this comment

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

PEP8 :) Should be spaces around =

@@ -338,7 +338,7 @@ def test_init_stdout_stderr(self):

def test_init_disable(self):
tc = TestCase('Disabled-Test')
tc.disable()
tc.is_enabled=False
Copy link
Collaborator

Choose a reason for hiding this comment

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

PEP8 :) Should be spaces around =

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.

2 participants