@@ -158,67 +158,67 @@ def test_loadcomponents(self):
158
158
)
159
159
160
160
161
- # class TestGenerateClasses(unittest.TestCase):
162
- # def setUp(self):
163
- # with open(METADATA_PATH, 'w') as f:
164
- # f.write(METADATA_STRING)
165
- # os.makedirs('default_namespace')
166
- #
167
- # init_file_path = 'default_namespace/__init__.py'
168
- # with open(init_file_path, 'a'):
169
- # os.utime(init_file_path, None)
170
- #
171
- # def tearDown(self):
172
- # os.remove(METADATA_PATH)
173
- # shutil.rmtree('default_namespace')
174
- #
175
- # def test_loadcomponents(self):
176
- # MyComponent_runtime = generate_class(
177
- # 'MyComponent',
178
- # METADATA['MyComponent.react.js']['props'],
179
- # METADATA['MyComponent.react.js']['description'],
180
- # 'default_namespace'
181
- # )
182
- #
183
- # A_runtime = generate_class(
184
- # 'A',
185
- # METADATA['A.react.js']['props'],
186
- # METADATA['A.react.js']['description'],
187
- # 'default_namespace'
188
- # )
189
- #
190
- # generate_classes('default_namespace', METADATA_PATH)
191
- # from default_namespace.MyComponent import MyComponent \
192
- # as MyComponent_buildtime
193
- # from default_namespace.A import A as A_buildtime
194
- #
195
- # MyComponentKwargs = {
196
- # 'foo': 42 ,
197
- # 'bar': 'Lah Lah',
198
- # 'baz': 'Lemons',
199
- # 'data-foo': 'Blah',
200
- # 'aria-bar': 'Seven',
201
- # 'baz': 'Lemons',
202
- # 'children': 'Child'
203
- # }
204
- # AKwargs = {
205
- # 'children': 'Child',
206
- # 'href': 'Hello World'
207
- # }
208
- #
209
- # self.assertTrue(
210
- # isinstance(
211
- # MyComponent_buildtime(**MyComponentKwargs),
212
- # Component
213
- # )
214
- # )
215
- #
216
- # self.assertEqual(
217
- # repr(MyComponent_buildtime(**MyComponentKwargs)),
218
- # repr(MyComponent_runtime(**MyComponentKwargs)),
219
- # )
220
- #
221
- # self.assertEqual(
222
- # repr(A_runtime(**AKwargs)),
223
- # repr(A_buildtime(**AKwargs))
224
- # )
161
+ class TestGenerateClasses (unittest .TestCase ):
162
+ def setUp (self ):
163
+ with open (METADATA_PATH , 'w' ) as f :
164
+ f .write (METADATA_STRING )
165
+ os .makedirs ('default_namespace' )
166
+
167
+ init_file_path = 'default_namespace/__init__.py'
168
+ with open (init_file_path , 'a' ):
169
+ os .utime (init_file_path , None )
170
+
171
+ def tearDown (self ):
172
+ os .remove (METADATA_PATH )
173
+ shutil .rmtree ('default_namespace' )
174
+
175
+ def test_loadcomponents (self ):
176
+ MyComponent_runtime = generate_class (
177
+ 'MyComponent' ,
178
+ METADATA ['MyComponent.react.js' ]['props' ],
179
+ METADATA ['MyComponent.react.js' ]['description' ],
180
+ 'default_namespace'
181
+ )
182
+
183
+ A_runtime = generate_class (
184
+ 'A' ,
185
+ METADATA ['A.react.js' ]['props' ],
186
+ METADATA ['A.react.js' ]['description' ],
187
+ 'default_namespace'
188
+ )
189
+
190
+ generate_classes ('default_namespace' , METADATA_PATH )
191
+ from default_namespace .MyComponent import MyComponent \
192
+ as MyComponent_buildtime
193
+ from default_namespace .A import A as A_buildtime
194
+
195
+ MyComponentKwargs = {
196
+ 'foo' : 'Hello World' ,
197
+ 'bar' : 'Lah Lah' ,
198
+ 'baz' : 'Lemons' ,
199
+ 'data-foo' : 'Blah' ,
200
+ 'aria-bar' : 'Seven' ,
201
+ 'baz' : 'Lemons' ,
202
+ 'children' : 'Child'
203
+ }
204
+ AKwargs = {
205
+ 'children' : 'Child' ,
206
+ 'href' : 'Hello World'
207
+ }
208
+
209
+ self .assertTrue (
210
+ isinstance (
211
+ MyComponent_buildtime (** MyComponentKwargs ),
212
+ Component
213
+ )
214
+ )
215
+
216
+ self .assertEqual (
217
+ repr (MyComponent_buildtime (** MyComponentKwargs )),
218
+ repr (MyComponent_runtime (** MyComponentKwargs )),
219
+ )
220
+
221
+ self .assertEqual (
222
+ repr (A_runtime (** AKwargs )),
223
+ repr (A_buildtime (** AKwargs ))
224
+ )
0 commit comments