cytoscape / ipycytoscape

A Cytoscape Jupyter widget
https://ipycytoscape.readthedocs.io/en/master/
BSD 3-Clause "New" or "Revised" License
261 stars 62 forks source link

Use pytest fixtures in edge tests #308

Closed jenshnielsen closed 2 years ago

jenshnielsen commented 2 years ago

Rather than defining the edges in line in the tests this uses a pytest fixture to define them This enables us to split the tests into individual functions without too much code duplication. That in turn fixes the test error in https://github.com/cytoscape/ipycytoscape/pull/300 It seems like copy.copy does not really do a deep copy (at least in the python 3.6 version used in github actions)

Since we are using a function scoped fixture recreated for each test we can drop the use of copy.copy

Note that if we use module scoped fixtures with copy.copy as in a0968e1df17b03e96484a1e7f41f085d55c89e79 I can reproduce the same error as in #300

github-actions[bot] commented 2 years ago

Binder :point_left: Launch a binder notebook on branch _jenshnielsen/ipycytoscape/edge_tests_usefixture

jenshnielsen commented 2 years ago

Alternatively this can also be solved using copy.deepcopy see https://github.com/jenshnielsen/ipycytoscape/pull/4 but I think pytest fixtures are a better approach

ianhi commented 2 years ago

This is fantastic thank you!