def test_construct_nonempty_theme_from_file(self): # windows will throw permissions error with auto-delete with (tempfile.NamedTemporaryFile(delete=False)) as file: # create and apply empty theme with no exception thrown file.file.write(FILE_CONTENTS) file.file.flush() theme = Theme(filename=file.name) assert dict(number=57) == theme._for_class(ThemedModel) assert dict(number=57, another_string="boo") == theme._for_class(SubOfThemedModel) file.close() os.remove(file.name)
def test_construct_nonempty_theme_from_file(self): # windows will throw permissions error with auto-delete with (tempfile.NamedTemporaryFile(delete=False)) as file: # create and apply empty theme with no exception thrown file.file.write(FILE_CONTENTS) file.file.flush() theme = Theme(filename=file.name) self.assertDictEqual(dict(number=57), theme._for_class(ThemedModel)) self.assertDictEqual(dict(number=57, another_string="boo"), theme._for_class(SubOfThemedModel)) file.close() os.remove(file.name)
def test_construct_nonempty_theme_from_file(self): with (tempfile.NamedTemporaryFile()) as file: # create and apply empty theme with no exception thrown file.file.write(""" attrs: ThemedModel: number: 57 SubOfThemedModel: another_string: "boo" """.encode('utf-8')) file.file.flush() theme = Theme(filename=file.name) self.assertDictEqual(dict(number=57), theme._for_class(ThemedModel)) self.assertDictEqual(dict(number=57, another_string="boo"), theme._for_class(SubOfThemedModel))
def test_construct_nonempty_theme_from_file(self): with (tempfile.NamedTemporaryFile()) as file: # create and apply empty theme with no exception thrown file.file.write(""" attrs: ThemedModel: number: 57 SubOfThemedModel: another_string: "boo" """.encode('utf-8')) file.file.flush() theme = Theme(filename=file.name) self.assertDictEqual(dict(number=57), theme._for_class(ThemedModel)) self.assertDictEqual(dict(number=57, another_string="boo"), theme._for_class(SubOfThemedModel))