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

Stix21master #275

Merged
merged 5 commits into from Jul 10, 2019
Merged

Stix21master #275

merged 5 commits into from Jul 10, 2019

Conversation

khdesai
Copy link
Contributor

@khdesai khdesai commented Jul 2, 2019

No description provided.

@chisholm
Copy link
Contributor

chisholm commented Jul 3, 2019

The errors seem to be the same in every case. It has to do with checking error messages, e.g.

assert 'is not a valid argument for a Start/Stop Qualifier' in str(excinfo)

The test error is always:

AssertionError: assert 'is not a valid argument for a Start/Stop Qualifier' in '<ExceptionInfo ValueError tblen=2>'
+  where '<ExceptionInfo ValueError tblen=2>' = str(<ExceptionInfo ValueError tblen=2>)

I think the problem is that the code str(excinfo) isn't producing what the test author expected. The author expected it to produce something which contains the error message associated with the ValueError. But pytest.raises actually produces a wrapper around the actual exception, and evidently the format of its str() isn't considered a stable public interface and something to be relied upon. I think to get the real error message, you should get the real exception, which is available as excinfo.value [1].

I think this may have only surfaced now because of a recent change to pytest. There is a changelog entry for 5.0.0 which mentions this [2]. This apparently came about from a github issue [3]. Looks to have been intentional, to keep people from getting confused about what the pytest.raises() contextmanager produces: if it's not the actual exception, its str() shouldn't make people think it's the actual exception. The "<ExceptionInfo ...>" format makes it clear that what you have is an ExceptionInfo wrapper.

To fix this, I think we need to change all instances of str(excinfo) to str(excinfo.value). Another option is to delete those checks, since as I've said, I don't think we should be checking human-targeted messages like this anyway.

What do you think?

  1. https://docs.pytest.org/en/latest/assert.html#assertraises
  2. https://docs.pytest.org/en/latest/changelog.html
  3. str() on the pytest.raises context variable doesn't behave same as normal exception catch pytest-dev/pytest#5412

@clenk
Copy link
Contributor

clenk commented Jul 3, 2019

I'm fine with removing those string comparison checks.

@codecov-io
Copy link

Codecov Report

Merging #275 into stix2.1 will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           stix2.1     #275      +/-   ##
===========================================
+ Coverage    98.64%   98.66%   +0.01%     
===========================================
  Files          120      122       +2     
  Lines        12921    13060     +139     
===========================================
+ Hits         12746    12885     +139     
  Misses         175      175
Impacted Files Coverage Δ
stix2/test/v21/test_core.py 100% <ø> (ø) ⬆️
stix2/test/v21/test_datastore_filters.py 100% <ø> (ø) ⬆️
stix2/v21/__init__.py 100% <ø> (ø) ⬆️
stix2/test/v21/test_bundle.py 100% <ø> (ø) ⬆️
stix2/test/v21/test_versioning.py 100% <ø> (ø) ⬆️
stix2/test/v21/test_workbench.py 72.72% <ø> (ø) ⬆️
stix2/test/v21/test_indicator.py 100% <100%> (ø) ⬆️
stix2/test/v21/test_infrastructure.py 100% <100%> (ø)
stix2/test/v21/constants.py 100% <100%> (ø) ⬆️
stix2/test/v20/test_datastore_filesystem.py 99.19% <100%> (-0.01%) ⬇️
... and 10 more

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 953a91b...b464a9c. Read the comment docs.

@emmanvg emmanvg self-requested a review July 10, 2019 14:32
Copy link
Contributor

@emmanvg emmanvg left a comment

Choose a reason for hiding this comment

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

@khdesai has removed the checks for the tests. The rest of the changes look good.

@emmanvg emmanvg merged commit b1fa177 into oasis-open:stix2.1 Jul 10, 2019
@khdesai khdesai deleted the stix21master branch July 10, 2019 15:05
@emmanvg emmanvg added this to the 1.2.0 milestone Sep 23, 2019
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

5 participants