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

DM-11725: Improve code coverage and numpydoc #51

Merged
merged 7 commits into from Jun 6, 2018
Merged

Conversation

timj
Copy link
Member

@timj timj commented Jun 5, 2018

I'm testing code coverage testing with pytest and as part of that I ended up improving test coverage in utils. I also tweaked the numpydoc a bit whilst I was there and ensured it is 79 column compliant.

@timj timj requested review from parejkoj and r-owen and removed request for parejkoj June 5, 2018 20:23
Copy link
Contributor

@r-owen r-owen 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. I had a few small requests

function has no class) is silently omitted, along with an associated separator.
An empty string is returned if `skip` exceeds the stack height.
Any item that cannot be determined (or is not relevant, e.g. a free
function function has no class) is silently omitted, along with an
Copy link
Contributor

Choose a reason for hiding this comment

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

Duplicated "function" (a pre-existing issue)

-------
name : `str`
Name of the caller as a string in the form ``module.class.method``.
An empty string is returned is ``skip`` exceeds the stack height.
Copy link
Contributor

Choose a reason for hiding this comment

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

"is" -> "if"

@@ -63,14 +63,20 @@


def _get_open_files():
"""Return a set containing the list of open files."""
"""Return a set containing the list of open files from this process.
Copy link
Contributor

Choose a reason for hiding this comment

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

What does "from this process" mean? Files that were opened by this process? Please reword or clarify in a longer description following the brief description.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reworded.

if psutil is None:
return set()
return set(p.path for p in psutil.Process().open_files())


def init():
"""Initialize the memory tester"""
"""Initialize the memory tester and leak tester."""
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the difference between the memory tester and the leak tester? I thought the memory tester tested for memory leaks. Please reword and/or clarify in a longer description.

Copy link
Member Author

Choose a reason for hiding this comment

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

clarification: file descriptor leak tester

@@ -80,7 +86,28 @@ def init():


def run(suite, exit=True):
"""Exit with the status code resulting from running the provided test suite"""
"""Exit with the status code resulting from running the provided test
suite
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a pre-existing issue, but the returned value is apparently the test exit status only if exit is True. Please consider changing this to something like Run a test suite

@@ -197,7 +238,7 @@ class ExecutablesTestCase(unittest.TestCase):
@classmethod
def setUpClass(cls):
"""Abort testing if automated test creation was enabled and
yet not tests were found."""
yet no tests were found."""
Copy link
Contributor

Choose a reason for hiding this comment

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

Good fix. Consider deleting "yet" as well

Path to an executable. ``root_dir`` is not used if this is an
absolute path.
root_dir : `str`, optional
Directory containing exe. Ignored if `None`.
Copy link
Contributor

Choose a reason for hiding this comment

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

"exe" -> "executable"; I realize this is pre-existing, but I find it very confusing, since file names for our executables do not end with .exe

@@ -262,16 +306,12 @@ def _build_test_method(cls, executable, root_dir):
The method is built for the supplied excutable located
in the supplied root directory.
Copy link
Contributor

Choose a reason for hiding this comment

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

I realize this is pre-existing, but... do you have any idea what means? I don't.

Copy link
Member Author

Choose a reason for hiding this comment

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

For each executable I create a new method that runs that executable. I attach that method to the test class so that pytest will find it and run the test method later.

msg="testexe.sh failed")

# Try a non-existent test
with self.assertRaises(Exception):
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you safely be more specific than Exception? Perhaps AssertionError? Similarly in several places below

@@ -31,7 +31,8 @@ class GetCallerNameTestCase(unittest.TestCase):
"""Test get_caller_name

Warning: due to the different ways this can be run
(e.g. directly or py.test, the module name can be one of two different things)
(e.g. directly or py.test, the module name can be one of two different
things)
Copy link
Contributor

Choose a reason for hiding this comment

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

Pre-existing, but please move the ) to just after py.test

and wrap at 79 characters.
@timj timj merged commit 860253a into master Jun 6, 2018
@ktlim ktlim deleted the tickets/DM-11725 branch August 25, 2018 05:57
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

2 participants