-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* small code changes - add deregister - add tests for register / deregister - replace relative imports with absoluts * update black version * change license to `Apache License, Version 2.0` * register all converters that are available in the __init__ * bugfix + change tests * remove no kwargs req * use mark.parametrize * small change
- Loading branch information
Showing
13 changed files
with
366 additions
and
309 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import pytest | ||
|
||
import znjson.converter | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def run_before_and_after_tests(): | ||
"""Fixture to execute before and after a test is run""" | ||
znjson.deregister(znjson.config.ACTIVE_CONVERTER) | ||
yield # this is where the testing happens | ||
znjson.register() | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"converters", | ||
( | ||
[], | ||
[znjson.converter.PathlibConverter], | ||
[znjson.converter.PathlibConverter, znjson.converter.PathlibConverter], | ||
[znjson.converter.PathlibConverter, znjson.converter.ClassConverter], | ||
), | ||
) | ||
def test_register(converters): | ||
znjson.register(converters) | ||
assert set(znjson.config.ACTIVE_CONVERTER) == set(converters) | ||
|
||
|
||
def test_register_PathlibConverter(): | ||
znjson.register(znjson.converter.PathlibConverter) | ||
assert znjson.config.ACTIVE_CONVERTER == [znjson.converter.PathlibConverter] | ||
|
||
|
||
def test_deregister_single(): | ||
znjson.register([znjson.converter.PathlibConverter, znjson.converter.ClassConverter]) | ||
|
||
znjson.deregister(znjson.converter.PathlibConverter) | ||
|
||
assert znjson.config.ACTIVE_CONVERTER == [znjson.converter.ClassConverter] | ||
|
||
|
||
def test_deregister_multiple(): | ||
znjson.register([znjson.converter.PathlibConverter, znjson.converter.ClassConverter]) | ||
|
||
znjson.deregister( | ||
[znjson.converter.PathlibConverter, znjson.converter.ClassConverter] | ||
) | ||
|
||
assert znjson.config.ACTIVE_CONVERTER == [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,6 @@ | |
|
||
import znjson | ||
|
||
znjson.register(znjson.PathlibConverter) | ||
|
||
|
||
@pytest.fixture | ||
def simple_dict(): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
from .base import ConverterBase | ||
from .config import config, register | ||
from .converter import * | ||
from .main import ZnDecoder, ZnEncoder | ||
from znjson.base import ConverterBase | ||
from znjson.config import config, deregister, register | ||
from znjson.converter import * | ||
from znjson.main import ZnDecoder, ZnEncoder | ||
|
||
__all__ = ["ConverterBase", "ZnDecoder", "ZnEncoder", "register", "config"] | ||
__all__ = ["ConverterBase", "ZnDecoder", "ZnEncoder", "register", "deregister", "config"] | ||
|
||
__version__ = "0.1.1" | ||
__version__ = "0.1.0" | ||
|
||
register() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters