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

Test on Python 3.7 and Python 3.8 #84

Merged
merged 9 commits into from
Jul 2, 2019
Merged

Conversation

rillian
Copy link
Contributor

@rillian rillian commented Jun 25, 2019

Remove unittest dependency, addressing #82, which unblocks adding travis jobs for current and upcoming python releases.

This file was using the `unittest` framework from the standard
library, but we invoke it through pytest. Remove the class
inheriting from unittest.TestCase and promote the methods
to module-level functions, which pytest's introspection
will still find.

The lexer member variable is replaced with a pytest fixture.

This removes a level of indirection (and indentation) and
makes it possible to use more advanced pytest features
like parametrization.
Use pytest's parametrization decorator instead of explicitly
looping with a helper. This gives finer-grained test feedback.
This set of tests were written to use the `unittest` framework
from the standard library but we were invoking them through pytest.

Remove the class and promote its methods to module-level functions.
The setUp method wasn't actually used, and self was only used to
lookup staticmethods, so there are otherwise few changes.
The open_file function is never called. The write_file function is
called once, but nothing is done with the result. If access to
test files is eventually needed, for example to implement
test_text_code_and_description, they're already available
through the the test.fixtures module.
Use a variable to compare input with serialization instead
of repeating the same text. This is less error-prone on
update.
These are no longer necessary for the current version of the code.
Since we call the parser and serializer with the default parameters,
there's not much value to wrapping the actual API calls this way.

The prefix/imperative style may be slightly easier to read than
the suffix/functional style, but I prefer making explicit what
functions are being called in the test.
None of the tests calling `compare_tokens` makes use of the lexer
fixture after passing it in. We can therefore avoid needing to
pass it through from every test by just creating a local lexer
inside that function.
Add a job testing on Python 3.7, which is the current stable
release. This required porting away from mixed pytest and
unittest for the particular versions of those libraries
available to the job.

Python 3.8 isn't in stable release yet, but it's good to get
advance warning on portability issues.
@rillian
Copy link
Contributor Author

rillian commented Jun 25, 2019

@ageorgou ready for review.

@ageorgou
Copy link
Contributor

@rillian I'm afraid I won't have time to review until next week, but I'll take a look as soon as I can. Thanks!

@rillian
Copy link
Contributor Author

rillian commented Jun 27, 2019

No worries. Thanks for the update!

Copy link
Contributor

@ageorgou ageorgou left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks! Only one minor question about the truncated docstring.

@@ -113,23 +113,21 @@ def test_text_code_and_description():
"""
Check if serializing works for the code/description case - first line
of ATF texts.
Note the parser always returns an AtfFile object, even when it's not
ATF-compliant.
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this no longer true (from previous updates), or did you just not consider it relevant? I'm guessing that it was here to make it clear that the test is meaningful, as the serializer always works on an AtfFile object rather than a plain string (although with the more transparent method calls, maybe this doesn't matter).

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 guessed similarly. I removed it because don't think it's correct for the current code. In the case of the project line test:

>>> from pyoracc.atf.common.atffile import AtfFile
>>> AtfFile("#project: cams/gkab\n")
[...]
SyntaxError: PyOracc could not parse token PROJECT at line 1 at offset 1 with value 'project'.

i.e. it fails without the preceding code and description line. I suppose it's partially correct in that if the required lines occur in order it will return an object with the missing values filled in with defaults, as happens with the code test, but either way I didn't find it helpful enough to include in the docstring.

These tests all look pretty easy to fix up, but I thought that should be a different PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense, thanks for catching that then!

@ageorgou ageorgou merged commit 645f1a7 into oracc:master Jul 2, 2019
@rillian rillian deleted the python3.8 branch July 2, 2019 15:44
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