Dorothydu's picture
Upload 50 random repository samples
9d3c8f5 verified
raw
history blame
1.51 kB
import unittest
from main import Schema # adjusted to import the Schema class from main.py
from genson import SchemaGenerationError
class TestMisuse(unittest.TestCase): # Updated to inherit from unittest.TestCase
def add_schema(self, schema_json):
# Assuming that you have a method to add schema that would log or handle it
# Placeholder for the actual implementation
pass
def test_schema_with_bad_type_error(self):
with self.assertRaises(SchemaGenerationError):
self.add_schema({'type': 'african swallow'})
def test_to_dict_pending_deprecation_warning(self):
with self.assertWarns(PendingDeprecationWarning):
builder = Schema() # Using the Schema from main.py
with self.assertWarns(PendingDeprecationWarning):
builder.add_object('I fart in your general direction!')
builder.to_dict() # Correctly using Schema's to_dict
def test_recurse_deprecation_warning(self):
with self.assertWarns(DeprecationWarning):
builder = Schema()
builder.add_object('Go away or I shall taunt you a second time!')
builder.to_dict(recurse=True)
def test_incompatible_schema_warning(self):
with self.assertWarns(UserWarning):
self.add_schema({'type': 'string', 'length': 5})
self.add_schema({'type': 'string', 'length': 7})
if __name__ == '__main__':
unittest.main() # Run the tests if this file is executed directly