Created
March 11, 2017 07:58
-
-
Save RJ722/34f06c0ffe2fb5f8b426761ac5ea9437 to your computer and use it in GitHub Desktop.
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
from itertools import chain | |
import unittest | |
class AspectInstanceTest(unittest.TestCase): | |
def test_tastes( | |
self, SubAspect, SubAspect_tastes, SubAspect_taste_values | |
): | |
using_default_values = SubAspect('py') | |
using_custom_values = SubAspect('py', **SubAspect_taste_values) | |
assert using_default_values.tastes == { | |
name: taste.default for name, taste in SubAspect_tastes.items()} | |
assert using_custom_values.tastes == SubAspect_taste_values | |
def test__setattr__(self, SubAspect, SubAspect_tastes): | |
aspect = SubAspect('py') | |
error_str_taste = "can't set taste values of aspectclass instances" | |
for name in SubAspect_tastes: | |
with self.assertRaisesRegex(AttributeError, error_str_taste): | |
setattr(aspect, name, 'value') | |
error_str_attr = "can't set attributes of aspectclass instances" | |
for name in ['docs', 'subaspects', 'tastes', '_tastes']: | |
with self.assertRaisesRegex(AttributeError, error_str_attr): | |
setattr(aspect, name, 'value') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment