Skip to content

Add utility to replace direct call to pytest.main#11393

Merged
areusch merged 1 commit into
apache:mainfrom
gigiblender:pytest-main-remove
May 23, 2022
Merged

Add utility to replace direct call to pytest.main#11393
areusch merged 1 commit into
apache:mainfrom
gigiblender:pytest-main-remove

Conversation

@gigiblender

@gigiblender gigiblender commented May 20, 2022

Copy link
Copy Markdown
Contributor

This PR replaces the test call to pytest.main

sys.exit(pytest.main([test_file] + sys.argv[1:]))

with a call to a utility function:

#11318

@gigiblender

Copy link
Copy Markdown
Contributor Author

@areusch

@areusch areusch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks @gigiblender this looks great! one request here

Comment thread tests/python/unittest/test_tvmscript_syntax_sugar.py Outdated
@gigiblender gigiblender force-pushed the pytest-main-remove branch from 48e81c7 to d70f300 Compare May 21, 2022 13:54
@gigiblender

Copy link
Copy Markdown
Contributor Author

thanks @gigiblender this looks great! one request here

@areusch I pushed the requested changes.

@driazati driazati left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice! just one small comment


def main():
test_file = inspect.getsourcefile(sys._getframe(1))
sys.exit(pytest.main([test_file] + sys.argv[1:]))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just a nit but do we actually need to determine and pass in the test file name? the examples don't seem to need it

Suggested change
sys.exit(pytest.main([test_file] + sys.argv[1:]))
sys.exit(pytest.main(sys.argv[1:]))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think running without a specified test file will cause pytest to search the current file for tests.

@areusch areusch left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks @gigiblender !

@areusch areusch merged commit 553eb1a into apache:main May 23, 2022
@gigiblender gigiblender deleted the pytest-main-remove branch May 23, 2022 20:42
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.

3 participants