Skip to content

Commit

Permalink
add UT for fqn
Browse files Browse the repository at this point in the history
  • Loading branch information
manatlan committed Jun 8, 2024
1 parent 3d310a6 commit 1e1c169
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
4 changes: 0 additions & 4 deletions htagweb/fqn.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,3 @@ def findfqn(x) -> str:
return tagClass.__module__+"."+tagClass.__qualname__


if __name__=="__main__":
class App(Tag.div):
pass
assert findfqn(App) == "htagweb.fqn.App" # not "__main__.App" !!!!!
28 changes: 28 additions & 0 deletions test_fqn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import pytest
from htag import Tag
from htagweb.fqn import findfqn

from examples import simple,main

class App(Tag.div):
pass

def test_fqn():
assert findfqn(App) == "test_fqn.App" # not "__main__.App" !!!!!

def test_fqn2():
assert findfqn("test_fqn.App") == "test_fqn.App"

def test_fqn3():
assert findfqn("test_fqn:App") == "test_fqn.App"

def test_fqn4():
assert findfqn(simple) == "examples.simple.App"

def test_module_without_App():
with pytest.raises(Exception): # Exception: module should contains a 'App' (htag.Tag class)
findfqn(main)

def test_bad_fqn():
with pytest.raises(Exception): # Exception: ...is not a 'full qualified name'
findfqn("main")

0 comments on commit 1e1c169

Please sign in to comment.