-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from ncilfone/maps
All the check are passed. Adds __map__ functionality is ready to be merged
- Loading branch information
Showing
10 changed files
with
379 additions
and
134 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,61 @@ | ||
# -*- coding: utf-8 -*- | ||
import sys | ||
|
||
from typing import List, Tuple, Optional | ||
|
||
import pytest | ||
|
||
from spock import spock | ||
from spock import SpockBuilder | ||
from spock.exceptions import _SpockInstantiationError | ||
|
||
|
||
class DummyClass: | ||
def __init__(self, value): | ||
self.value = value | ||
|
||
|
||
class TestMaps: | ||
def test_return_raise(self, monkeypatch, tmp_path): | ||
with monkeypatch.context() as m: | ||
m.setattr( | ||
sys, | ||
"argv", | ||
[""], | ||
) | ||
with pytest.raises(_SpockInstantiationError): | ||
|
||
@spock | ||
class FailReturnConfig: | ||
val_1: float = 0.5 | ||
|
||
def __maps__(self): | ||
print(self.val_1) | ||
|
||
config = SpockBuilder( | ||
FailReturnConfig, | ||
desc="Test Builder", | ||
) | ||
config.generate() | ||
|
||
def test_map_return(self, monkeypatch, tmp_path): | ||
with monkeypatch.context() as m: | ||
m.setattr( | ||
sys, | ||
"argv", | ||
[""], | ||
) | ||
|
||
@spock | ||
class ReturnConfig: | ||
val_1: float = 0.5 | ||
|
||
def __maps__(self): | ||
return DummyClass(value=self.val_1) | ||
|
||
config = SpockBuilder( | ||
ReturnConfig, | ||
desc="Test Builder", | ||
) | ||
configs = config.generate() | ||
assert configs.ReturnConfig._maps.value == configs.ReturnConfig.val_1 |
Oops, something went wrong.