diff --git a/graphene/types/options.py b/graphene/types/options.py
index 50e982c7..0002db68 100644
--- a/graphene/types/options.py
+++ b/graphene/types/options.py
@@ -19,18 +19,18 @@ class Options(object):
for attr_name, value in defaults.items():
if attr_name in meta_attrs:
value = meta_attrs.pop(attr_name)
- elif hasattr(meta, attr_name):
- value = getattr(meta, attr_name)
setattr(self, attr_name, value)
- # If meta_attrs is not empty, it implicit means
+ # If meta_attrs is not empty, it implicitly means
# it received invalid attributes
if meta_attrs:
raise TypeError(
"Invalid attributes: {}".format(
- ','.join(meta_attrs.keys())
+ ', '.join(sorted(meta_attrs.keys()))
)
)
def __repr__(self):
- return ''.format(props(self))
+ options_props = props(self)
+ props_as_attrs = ' '.join(['{}={}'.format(key, value) for key, value in options_props.items()])
+ return ''.format(props_as_attrs)
diff --git a/graphene/types/tests/test_options.py b/graphene/types/tests/test_options.py
new file mode 100644
index 00000000..fbcba2db
--- /dev/null
+++ b/graphene/types/tests/test_options.py
@@ -0,0 +1,30 @@
+import pytest
+
+from ..options import Options
+
+
+def test_options():
+ class BaseOptions:
+ option_1 = False
+ name = True
+ meta = Options(BaseOptions, name=False, option_1=False)
+ assert meta.name == True
+ assert meta.option_1 == False
+
+
+def test_options_extra_attrs():
+ class BaseOptions:
+ name = True
+ type = True
+
+ with pytest.raises(Exception) as exc_info:
+ meta = Options(BaseOptions)
+
+ assert str(exc_info.value) == 'Invalid attributes: name, type'
+
+
+def test_options_repr():
+ class BaseOptions:
+ name = True
+ meta = Options(BaseOptions, name=False)
+ assert repr(meta) == ''