Skip to content

Instantly share code, notes, and snippets.

@RJ722
Created March 11, 2017 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RJ722/34f06c0ffe2fb5f8b426761ac5ea9437 to your computer and use it in GitHub Desktop.
Save RJ722/34f06c0ffe2fb5f8b426761ac5ea9437 to your computer and use it in GitHub Desktop.
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