moremoban / moban

General purpose static text generator using Jinja2 and other python template engines
http://moban.readthedocs.io
MIT License
33 stars 14 forks source link

Switch to pytest/nose2/unittest #364

Closed paolostivanin closed 4 years ago

paolostivanin commented 4 years ago

Hello, just a heads-up that nose will no longer work with python 3.9/3.10+ :)

chfw commented 4 years ago

Thanks for the heads-up. Any reference or pointer regarding it please. I knew nose development was stopped.

paolostivanin commented 4 years ago

https://tirkarthi.github.io/programming/2020/01/27/python-39-changes.html

mcepl commented 4 years ago

I was thinking about something like remove_nose.patch, but I got zillion failures, which don't seem like a product of my effort. See full build log.

chfw commented 4 years ago

could it because of this one? https://github.com/moremoban/moban/blob/dev/tests/__init__.py

nose would load init.py

pgajdos commented 4 years ago

I am on it right now.

-class TestHandleTemplateFunction:
+class TestHandleTemplateFunction(unittest.TestCase):
     def setUp(self):
         self.base_dir = [fs.path.join("tests", "fixtures")]

nose runs setUp(), but pytest does not when you do not derive from unittest.TestCase.

I hope I am very near to the solution with: https://build.opensuse.org/package/view_file/home:pgajdos:python/python-moban/python-moban-remove-nose.patch

Last thing I need to resolve is:

[    6s] /usr/lib/python3.8/site-packages/lml/plugin.py:290: in load_me_now
[    6s]     self.raise_exception(key)
[    6s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
[    6s]
[    6s] self = <moban.core.moban_factory.MobanFactory object at 0x7f7b5c027460>
[    6s] key = 'copy'
[    6s]
[    6s]     def raise_exception(self, key):
[    6s] >       raise exceptions.NoThirdPartyEngine(key)
[    6s] E       moban.exceptions.NoThirdPartyEngine: copy
[    6s]
[    6s] moban/core/moban_factory.py:82: NoThirdPartyEngine
pgajdos commented 4 years ago

@mcepl, @chfw, would you have any idea how it should be fixed?

mcepl commented 4 years ago

@mcepl, @chfw, would you have any idea how it should be fixed?

Could you publish whole log, I am afraid, you have posted here just the end of the error message?

pgajdos commented 4 years ago

Sure, here it is: https://build.opensuse.org/package/live_build_log/home:pgajdos:python/python-moban/openSUSE_Factory/x86_64

pgajdos commented 4 years ago

copy.py is one of plugins under moban/plugins.

pgajdos commented 4 years ago

(So I guess it is just not found.)

chfw commented 4 years ago

load_engine_factory_and_engines() should be called before the unit test start.

pgajdos commented 4 years ago

could it because of this one? https://github.com/moremoban/moban/blob/dev/tests/__init__.py

nose would load init.py

Yep, setup() from there seem not to be called.

pgajdos commented 4 years ago

This works, is that acceptable?

--- __init.py.orig      2020-09-21 12:30:35.503025296 +0000
+++ __init__.py 2020-09-21 12:30:44.911084197 +0000
@@ -1,5 +1,4 @@
 from moban.main import load_engine_factory_and_engines

-def setup():
-    load_engine_factory_and_engines()
+load_engine_factory_and_engines()
mcepl commented 4 years ago

Perhaps as setUpClass() or setUpModule() https://docs.python.org/3/library/unittest.html?highlight=setup#class-and-module-fixtures ?

pgajdos commented 4 years ago

Yes, this works as well.