コード例 #1
0
def test_concern_level():
	concern = Concern(CRITICAL, "This is a sample catastrophic failure.")
	assert concern.level == CRITICAL
	assert unicode(concern) == "This is a sample catastrophic failure."
	assert repr(concern) == 'Concern(CRITICAL, "This is a sample catastrophic failure.")'
	
	concern = Concern(WARNING, "This is a sample warning.")
	assert concern.level == WARNING
	assert unicode(concern) == "This is a sample warning."
	assert repr(concern) == 'Concern(WARNING, "This is a sample warning.")'
コード例 #2
0
ファイル: test_alias.py プロジェクト: marrow/mongo
	def test_deprecated_access(self):
		inst = self.Sample.from_mongo({'field': 'foo'})
		
		with warnings.catch_warnings(record=True) as w:
			warnings.simplefilter('always')
			
			assert inst.deprecated == 'foo'
			
			assert len(w) == 1
			assert issubclass(w[-1].category, DeprecationWarning)
			assert 'via deprecated' in unicode(w[-1].message)
			assert 'xyzzy' in unicode(w[-1].message)
コード例 #3
0
ファイル: test_alias.py プロジェクト: bb78657/mongo
    def test_deprecated_access(self):
        inst = self.Sample.from_mongo({'field': 'foo'})

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')

            assert inst.deprecated == 'foo'

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert 'via deprecated' in unicode(w[-1].message)
            assert 'xyzzy' in unicode(w[-1].message)
コード例 #4
0
def test_concern_level():
    concern = Concern(CRITICAL, "This is a sample catastrophic failure.")
    assert concern.level == CRITICAL
    assert unicode(concern) == "This is a sample catastrophic failure."
    assert repr(
        concern
    ) == 'Concern(CRITICAL, "This is a sample catastrophic failure.")'

    concern = Concern(WARNING, "This is a sample warning.")
    assert concern.level == WARNING
    assert unicode(concern) == "This is a sample warning."
    assert repr(concern) == 'Concern(WARNING, "This is a sample warning.")'
コード例 #5
0
ファイル: test_alias.py プロジェクト: bb78657/mongo
    def test_deprecated_assignment(self):
        inst = self.Sample()

        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')

            inst.deprecated = 'bar'

            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            assert 'via deprecated' in unicode(w[-1].message)
            assert 'xyzzy' in unicode(w[-1].message)

        assert inst.__data__ == {'field': 'bar'}
コード例 #6
0
ファイル: test_alias.py プロジェクト: marrow/mongo
	def test_deprecated_assignment(self):
		inst = self.Sample()
		
		with warnings.catch_warnings(record=True) as w:
			warnings.simplefilter('always')
			
			inst.deprecated = 'bar'
			
			assert len(w) == 1
			assert issubclass(w[-1].category, DeprecationWarning)
			assert 'via deprecated' in unicode(w[-1].message)
			assert 'xyzzy' in unicode(w[-1].message)
		
		assert inst.__data__ == {'field': 'bar'}
コード例 #7
0
ファイル: test_base.py プロジェクト: marrow/schema
 def test_raises(self):
     try:
         self.raises.validate(None)
     except Concern as e:
         assert unicode(e) == "Oh my no."
     else:
         assert False, "Failed to raise a Concern."
コード例 #8
0
ファイル: test_base.py プロジェクト: lokeshmeher/schema
	def test_raises(self):
		try:
			self.raises.validate(None)
		except Concern as e:
			assert unicode(e) == "Oh my no."
		else:
			assert False, "Failed to raise a Concern."
コード例 #9
0
ファイル: test_base.py プロジェクト: lokeshmeher/schema
	def _do(self, validator):
		assert validator.validate([1, 27, 42]) == [1, 27, 42]
		
		try:
			validator.validate([1, 2, 3])
		except Concern as e:
			assert unicode(e).startswith("Value does not contain: ")
		else:
			assert False, "Failed to raise a Concern."
コード例 #10
0
ファイル: test_base.py プロジェクト: marrow/schema
    def _do(self, validator):
        assert validator.validate([1, 27, 42]) == [1, 27, 42]

        try:
            validator.validate([1, 2, 3])
        except Concern as e:
            assert unicode(e).startswith("Value does not contain: ")
        else:
            assert False, "Failed to raise a Concern."
コード例 #11
0
def do_deprecation(value):
	cls, dst = value
	
	with warnings.catch_warnings(record=True) as w:
		warnings.simplefilter('always')
		
		cls()
		
		assert len(w) == 1, "Only one warning should be raised."
		assert issubclass(w[-1].category, DeprecationWarning), "Warning must be a DeprecationWarning."
		assert dst in unicode(w[-1].message), "Warning should mention correct class to use."
コード例 #12
0
def do_deprecation(value):
    cls, dst = value

    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')

        cls()

        assert len(w) == 1, "Only one warning should be raised."
        assert issubclass(
            w[-1].category,
            DeprecationWarning), "Warning must be a DeprecationWarning."
        assert dst in unicode(
            w[-1].message), "Warning should mention correct class to use."
コード例 #13
0
def test_depreciated_validation_import():
	with warnings.catch_warnings(record=True) as w:
		warnings.simplefilter('always')
		
		import marrow.schema.validation
		import marrow.schema.validation.base
		import marrow.schema.validation.compound
		import marrow.schema.validation.date
		import marrow.schema.validation.geo
		import marrow.schema.validation.network
		import marrow.schema.validation.pattern
		import marrow.schema.validation.testing
		import marrow.schema.validation.util
		
		assert len(w) == 1, "Only one warning should be raised."
		assert issubclass(w[-1].category, DeprecationWarning), "Warning must be DeprecationWarning."
		assert 'marrow.schema.validate' in unicode(w[-1].message), "Warning should mention correct module to import."
コード例 #14
0
def test_depreciated_validation_import():
    with warnings.catch_warnings(record=True) as w:
        warnings.simplefilter('always')

        import marrow.schema.validation
        import marrow.schema.validation.base
        import marrow.schema.validation.compound
        import marrow.schema.validation.date
        import marrow.schema.validation.geo
        import marrow.schema.validation.network
        import marrow.schema.validation.pattern
        import marrow.schema.validation.testing
        import marrow.schema.validation.util

        assert len(w) == 1, "Only one warning should be raised."
        assert issubclass(
            w[-1].category,
            DeprecationWarning), "Warning must be DeprecationWarning."
        assert 'marrow.schema.validate' in unicode(
            w[-1].message), "Warning should mention correct module to import."
コード例 #15
0
def test_basic_concern_text_replacement():
    concern = Concern("{who} has failed me for the {times} time.",
                      who="Bob Dole",
                      times="last")
    assert unicode(concern) == "Bob Dole has failed me for the last time."
コード例 #16
0
ファイル: test_q.py プロジェクト: bb78657/mongo
 def test_operator_invert(self):
     assert unicode(Sample.generic) == ~Sample.generic == 'generic'
コード例 #17
0
ファイル: test_base.py プロジェクト: lokeshmeher/schema
	def test_concern(self):
		try:
			self.transform('x')
		except Concern as e:
			assert self.direction in unicode(e)
			assert 'invalid literal' in unicode(e)
コード例 #18
0
ファイル: test_path.py プロジェクト: bb78657/mongo
	def test_native_conversion(self, Sample):
		inst = Sample.from_mongo({'field': '/foo'})
		value = inst.field
		assert isinstance(value, _Path)
		assert unicode(value) == '/foo'
コード例 #19
0
def test_basic_concern_text():
	concern = Concern("This is a sample failure.")
	assert unicode(concern) == "This is a sample failure."
コード例 #20
0
ファイル: test_q.py プロジェクト: marrow/mongo
	def test_operator_invert(self):
		assert unicode(Sample.generic) == ~Sample.generic == 'generic'
コード例 #21
0
def test_basic_concern_positional_replacement():
	concern = Concern("{0} has failed me for the {1} time.", "Bob Dole", "last")
	assert unicode(concern) == "Bob Dole has failed me for the last time."
コード例 #22
0
ファイル: test_q.py プロジェクト: marrow/mongo
	def test_s(self):
		assert unicode(Sample.array.S) == 'field_name.$'
コード例 #23
0
def test_basic_concern_text_replacement():
	concern = Concern("{who} has failed me for the {times} time.", who="Bob Dole", times="last")
	assert unicode(concern) == "Bob Dole has failed me for the last time."
コード例 #24
0
def test_basic_concern_text():
    concern = Concern("This is a sample failure.")
    assert unicode(concern) == "This is a sample failure."
コード例 #25
0
ファイル: test_q.py プロジェクト: marrow/mongo
	def test_embedded(self):
		assert unicode(Sample.embed.name) == 'embed.name'
コード例 #26
0
ファイル: test_q.py プロジェクト: bb78657/mongo
 def test_embedded(self):
     assert unicode(Sample.embed.name) == 'embed.name'
コード例 #27
0
ファイル: test_objectid.py プロジェクト: bb78657/mongo
	def test_cast_string(self, Sample):
		inst = Sample('5832223f927cc6c1a10609f7')
		
		assert isinstance(inst.__data__['field'], oid)
		assert unicode(inst.field) == '5832223f927cc6c1a10609f7'
コード例 #28
0
def test_basic_concern_positional_replacement():
    concern = Concern("{0} has failed me for the {1} time.", "Bob Dole",
                      "last")
    assert unicode(concern) == "Bob Dole has failed me for the last time."
コード例 #29
0
ファイル: test_q.py プロジェクト: bb78657/mongo
 def test_s(self):
     assert unicode(Sample.array.S) == 'field_name.$'