Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(8)  |  Call(6)  |  Derive(0)  |  Import(2)

src/c/o/cogent-1.5.3/tests/test_parse/test_record.py   cogent(Download)
#!/usr/bin/env python
"""Unit tests for parser support libraries dealing with records.
"""
from cogent.parse.record import FieldError, RecordError, Grouper, \
    DelimitedSplitter, GenericRecord, MappedRecord, \
    def test_default(self):
        """FieldMorpher default should use correct constructors"""
        fm = FieldMorpher({'a':int, 'b':str})
        self.assertEqual(fm({'a':'3', 'b':456}), {'a':3,'b':'456'})
 
    def test_default_error(self):
        """FieldMorpher default should raise FieldError on unknown fields"""
        fm = FieldMorpher({'a':int, 'b':str})
    def test_altered_default(self):
        """FieldMorpher with default set should apply it"""
        func = lambda x, y: (str(x), float(y) - 0.5)
        fm = FieldMorpher({'3':str,4:int}, func)
        #check that recognized values aren't tampered with

src/p/y/pycogent-HEAD/tests/test_parse/test_record.py   pycogent(Download)
#!/usr/bin/env python
"""Unit tests for parser support libraries dealing with records.
"""
from cogent.parse.record import FieldError, RecordError, Grouper, \
    DelimitedSplitter, GenericRecord, MappedRecord, \
    def test_default(self):
        """FieldMorpher default should use correct constructors"""
        fm = FieldMorpher({'a':int, 'b':str})
        self.assertEqual(fm({'a':'3', 'b':456}), {'a':3,'b':'456'})
 
    def test_default_error(self):
        """FieldMorpher default should raise FieldError on unknown fields"""
        fm = FieldMorpher({'a':int, 'b':str})
    def test_altered_default(self):
        """FieldMorpher with default set should apply it"""
        func = lambda x, y: (str(x), float(y) - 0.5)
        fm = FieldMorpher({'3':str,4:int}, func)
        #check that recognized values aren't tampered with