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

RFC / RFE - testing python with more than just 'import' #1367

Open
smoser opened this issue Jul 11, 2024 · 0 comments
Open

RFC / RFE - testing python with more than just 'import' #1367

smoser opened this issue Jul 11, 2024 · 0 comments

Comments

@smoser
Copy link
Contributor

smoser commented Jul 11, 2024

The python/import test is very nice, with 'imports' and makes testing import very easy. I'd like to be able to do some more complex tests, and thought a pipeline would be useful.

The py3-pytest-timeout package currently has a test that uses py3-pytest. Its test stanza is kind of cludgy involving shell grep/exit, which is painful and has high potential for footgun.

I think it would be nice to have at very least something like this:

test:
  pipeline:
    - uses: python/tests
      tests:
       - content: |
           import foo
           assert(foo.version == "${{package.version}}")
       - content: |
           import bar
           ....

My second thought there is that it might be useful to run those with pytest, to allow the sort of things that pytest buys you.

test:
  pipeline:
    - uses: python/tests
      tests:
        - content: |
          import time
          def test_verify_stuff():
             """verify the stuff"""
             ...

Things I like about this:

  • it is all in the yaml file - you don't have to go lookiong elsewhere, and changes to the package aren't possibly "hidden" in a / directory.
  • one place to execute the things (the python) so each yaml file doesn't have to implement a correct execution

Things I don't like:

  • it is all in the yaml file - makes long noisy yaml files and not so easy to just run the same tests manually.

This is a RFC/RFE, I really think we can do better with tests and I think we need to, so that writing them is easier.

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

No branches or pull requests

1 participant