Ejemplo n.º 1
0
    def test_type_parsing(self):
        # Test parsing type of attribute from their value.
        with open(test2) as ofile:
            rel, attrs = read_header(ofile)

        expected = [
            'numeric', 'numeric', 'numeric', 'numeric', 'numeric', 'numeric',
            'string', 'string', 'nominal', 'nominal'
        ]

        for i in range(len(attrs)):
            assert_(attrs[i].type_name == expected[i])
Ejemplo n.º 2
0
    def test_fullheader1(self):
        # Parsing trivial header with nothing.
        with open(test1) as ofile:
            rel, attrs = read_header(ofile)

        # Test relation
        assert_(rel == 'test1')

        # Test numerical attributes
        assert_(len(attrs) == 5)
        for i in range(4):
            assert_(attrs[i].name == 'attr%d' % i)
            assert_(attrs[i].type_name == 'numeric')

        # Test nominal attribute
        assert_(attrs[4].name == 'class')
        assert_(attrs[4].values == ('class0', 'class1', 'class2', 'class3'))
Ejemplo n.º 3
0
    def test_dateheader(self):
        with open(test7) as ofile:
            rel, attrs = read_header(ofile)

        assert_(rel == 'test7')

        assert_(len(attrs) == 5)

        assert_(attrs[0].name == 'attr_year')
        assert_(attrs[0].date_format == '%Y')

        assert_(attrs[1].name == 'attr_month')
        assert_(attrs[1].date_format == '%Y-%m')

        assert_(attrs[2].name == 'attr_date')
        assert_(attrs[2].date_format == '%Y-%m-%d')

        assert_(attrs[3].name == 'attr_datetime_local')
        assert_(attrs[3].date_format == '%Y-%m-%d %H:%M')

        assert_(attrs[4].name == 'attr_datetime_missing')
        assert_(attrs[4].date_format == '%Y-%m-%d %H:%M')
Ejemplo n.º 4
0
 def read_dateheader_unsupported():
     with open(test8) as ofile:
         _, _ = read_header(ofile)
Ejemplo n.º 5
0
 def badtype_read():
     with open(test3) as ofile:
         _, _ = read_header(ofile)