Billingegroup / cookiecutter

A cookie-cutter for DiffPy packages.
Other
0 stars 7 forks source link

Replace source code: <package>/test/__init__.py and run.py #51

Closed Tieqiong closed 3 weeks ago

Tieqiong commented 3 weeks ago

fix #25

sbillinge commented 3 weeks ago

We want to run tests using pytest moving forward. @Sparks29032 do we want to modify (get rid of) anything here before merging?

Sparks29032 commented 3 weeks ago

Shoot, I missed the notification on this thread! I think we actually want to keep __init__.py blank. Let me check if we can remove this from diffpy.utils.

Sparks29032 commented 3 weeks ago

@Tieqiong @sbillinge I think we keep __init__.py blank and change run.py to

#!/usr/bin/env python
##############################################################################
#
# (c) {% now 'utc', '%Y' %} The Trustees of Columbia University in the City of New York.
# All rights reserved.
#
# File coded by: Billinge Group members and community contributors.
#
# See GitHub contributions for a more detailed list of contributors.
# https://github.com/{{ cookiecutter.github_org }}/{{ cookiecutter.repo_name }}/graphs/contributors
#
# See LICENSE.rst for license information.
#
##############################################################################
"""Convenience module for executing all unit tests with
python -m {{ cookiecutter.project_name }}.tests.run
"""

import sys
import pytest

if __name__ == "__main__":
    # show output results from every test function
    args = ["-v"]
    # show the message output for skipped and expected failure tests
    if len(sys.argv) > 1:
        args.extend(sys.argv[1:])
    print("pytest arguments: {}".format(args))
    # call pytest and exit with the return code from pytest
    exit_res = pytest.main(args)
    sys.exit(exit_res)

# End of file

This preserves python -m <package>.tests.run. @Tieqiong make sure after building you test the package with pytest. I tested locally and it seems fine, but I would like a second look.

Tieqiong commented 3 weeks ago

closing, see #71

sbillinge commented 3 weeks ago

@Tieqiong what is the reason why you are closing this? I understand that you replaced it with a new PR. We sometimes do that when a PR gets a messy history we don't want, for example, but I just want to double check that you know it is ok to work on PRs till they are fixed in general. We don't have to always close them.