question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TST: Remove arbitrary pytest markers and replace ccd_data fixture

See original GitHub issue

As @bsipocz pointed out, pytest emits the following warning in nddata tests (turned into error in this exercise), which we currently ignore:

__ ERROR collecting astropy/nddata/tests/test_ccddata.py __
astropy/nddata/tests/test_ccddata.py:98: in <module>
    @pytest.mark.data_size(10)
.../_pytest/mark/structures.py:337: in __getattr__
    PytestUnknownMarkWarning,
E   _pytest.warning_types.PytestUnknownMarkWarning: Unknown pytest.mark.data_size
- is this a typo?  You can register custom marks to avoid this warning
- for details, see https://docs.pytest.org/en/latest/mark.html

This is because of

https://github.com/astropy/astropy/blob/a22c724006036c1ddf5e68aa896ae90bf7e0b6a0/astropy/nddata/tests/test_ccddata.py#L38-L43

https://github.com/astropy/astropy/blob/a22c724006036c1ddf5e68aa896ae90bf7e0b6a0/astropy/nddata/tests/test_ccddata.py#L46-L47

https://github.com/astropy/astropy/blob/a22c724006036c1ddf5e68aa896ae90bf7e0b6a0/astropy/nddata/tests/test_ccddata.py#L64

https://github.com/astropy/astropy/blob/a22c724006036c1ddf5e68aa896ae90bf7e0b6a0/astropy/nddata/tests/test_ccddata.py#L98-L99

I think the tests would still work if we remove ccd_data as a fixture, but rather re-implements it as a helper function that takes all those custom markers as regular arguments. Better yet, we can memoize that function so that requesting array of same size will return a cached copy instead of creating a new one from scratch (more memory usage but better performance). Given that ccd_data generates random number and there is no reason why randomness has to be that random between different unit tests, memoization is probably okay?

What do you think, @mwcraig , @crawfordsm , or @MSeifert04 ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
MSeifert04commented, Jun 20, 2019

Okay, seems like we all agree. I could have a look into this if none of you is already working on that.

1reaction
mwcraigcommented, Jun 20, 2019

go for it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Working with custom markers — pytest documentation
You can “mark” a test function with custom metadata like this: ... Nodes are also created for each parameter of a parametrized fixture...
Read more >
Disable autouse fixtures on specific pytest marks
Maybe you could do something to change the autouse fixture based on a mark's condition. But this would be hackish and difficult. possibly...
Read more >
pytest Documentation - Read the Docs
pytest provides Builtin fixtures/function arguments to request arbitrary resources, like a unique temporary directory:.
Read more >
Deep dive into Pytest parametrization | by George Shuklin
Pytest is an amazing testing framework for Python. In this article I will focus on how fixture parametrization translates into test parametrization in ......
Read more >
Customizing your pytest test suite (part 2) - Raphael Pierzina
Add a custom marker · Write a new test that combines all scenarios · Delete now redundant tests · Write plugin to deselect...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found