kivy-garden / graph

Displays plots on a graph.
MIT License
50 stars 18 forks source link

MeshLinePlot prevents unit tests from running #30

Closed s-kganz closed 4 years ago

s-kganz commented 4 years ago

Describe the bug Instantiating a MeshLinePlot anywhere in a unit testing script prevents pytest and unittest from discovering and running tests.

To Reproduce Uncomment either MeshLinePlot() call in the below script.

# test_container.py
import unittest
from kivy_garden.graph import MeshLinePlot

#mesh = MeshLinePlot()

class Container():
    def __init__(self, id):
        self.id = id
        #self.mesh = MeshLinePlot()

class TestOne(unittest.TestCase):
    def test_dummy(self):
        print('In dummy_test()')
        self.assertEqual(1, 1)

    def test_class_init(self):
        print('In test_class_init()')
        c = Container(1)
        self.assertEqual(c.id, 1)

if __name__ == '__main__':
    unittest.main()

Expected behavior Unit tests are discovered and run as expected with pytest and/or unittest.

Logs/output Result when uncommenting the instantiation in Container:

> python test_container.py
[INFO   ] [Logger      ] Record log in C:\Users\ganzk\.kivy\logs\kivy_20-07-28_13.txt
[INFO   ] [deps        ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO   ] [deps        ] Successfully imported "kivy_deps.sdl2" 0.2.0
[INFO   ] [Kivy        ] v1.11.1
[INFO   ] [Kivy        ] Installed at "c:\Users\ganzk\Desktop\peaks\kivy_env\lib\site-packages\kivy\__init__.py"
[INFO   ] [Python      ] v3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 22:22:05) [MSC v.1916 64 bit (AMD64)]
[INFO   ] [Python      ] Interpreter at "c:\Users\ganzk\Desktop\peaks\kivy_env\Scripts\python.exe"
[INFO   ] [Factory     ] 184 symbols loaded
[INFO   ] [Image       ] Providers: img_tex, img_dds, img_sdl2, img_pil, img_gif (img_ffpyplayer ignored)
[INFO   ] [Text        ] Provider: sdl2
In test_class_init()

Using pytest instead:

=== test session starts ===
> pytest test_container.py
platform win32 -- Python 3.7.3, pytest-5.4.3, py-1.9.0, pluggy-0.13.1
rootdir: C:\Users\ganzk\Desktop\peaks
collected 0 items                                                                                                                                      
== no tests ran in 0.00s ==

Platform (please complete the following information):

s-kganz commented 4 years ago

My bad, unit tests using any kivy graphics instruction need to inherit from the proper test case class. Not an issue with this repo at all. See the SO thread here for a working version of the above script.