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

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

Closed
wants to merge 2 commits into from

Conversation

Tieqiong
Copy link
Contributor

@Tieqiong Tieqiong commented Jun 20, 2024

fix #25

@sbillinge
Copy link
Collaborator

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

@Sparks29032
Copy link
Collaborator

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
Copy link
Collaborator

@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 Tieqiong mentioned this pull request Jun 21, 2024
@Tieqiong
Copy link
Contributor Author

closing, see #71

@Tieqiong Tieqiong closed this Jun 21, 2024
@sbillinge
Copy link
Collaborator

@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.

@Tieqiong Tieqiong deleted the testrun branch June 22, 2024 06:07
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.

diffpy/<package>/tests/run.py
3 participants