summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--test/tc_ext.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/tc_ext.py b/test/tc_ext.py
index ea82bbfe..2ee4a407 100644
--- a/test/tc_ext.py
+++ b/test/tc_ext.py
@@ -89,6 +89,32 @@ class TestCases(unittest.TestCase):
 		# self.assertEqual('/media/foo',
 		#     mount_path('/media/bar/some_link_to_a_foo_subdirectory'))
 
+	def test_openstruct(self):
+		from ranger.ext.openstruct import OpenStruct
+		from random import randint, choice
+		from string import ascii_letters
+
+		os = OpenStruct(a='a')
+		self.assertEqual(os.a, 'a')
+		self.assertRaises(AttributeError, getattr, os, 'b')
+
+		dictionary = {'foo': 'bar', 'zoo': 'zar'}
+		os = OpenStruct(dictionary)
+		self.assertEqual(os.foo, 'bar')
+		self.assertEqual(os.zoo, 'zar')
+		self.assertRaises(AttributeError, getattr, os, 'sdklfj')
+
+		for i in range(100):
+			attr_name = ''.join(choice(ascii_letters) \
+				for x in range(randint(3,9)))
+			value = randint(100,999)
+			if not attr_name in os:
+				self.assertRaises(AttributeError, getattr, os, attr_name)
+			setattr(os, attr_name, value)
+			value2 = randint(100,999)
+			setattr(os, attr_name, value2)
+			self.assertEqual(value2, getattr(os, attr_name))
+
 
 if __name__ == '__main__':
 	unittest.main()
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144