'Test parsing of media queries from the CSS 3 media module'

def test_media_queries(self):

    for (css, media_query_list, expected_errors) in [(u'@media    {}', [MQ()], []), (u'@media    all    {}', [MQ()], []), (u'@media    screen    {}', [MQ(u'screen')], []), (u'@media    ,    screen    {}', [MQ(), MQ(u'screen')], []), (u'@media    screen,    {}', [MQ(u'screen'), MQ()], []), (u'@media    screen    and    (color)    {}', [MQ(u'screen', ((u'color', None),))], []), (u'@media    all    and    (min-width:500px)    {}', [MQ(u'all', ((u'min-width', (u'DIMENSION', 500)),))], []), (u'@media    (min-width:500px)    {}', [MQ(u'all', ((u'min-width', (u'DIMENSION', 500)),))], []), (u'@media    (orientation:    portrait)    {}', [MQ(u'all', ((u'orientation', (u'IDENT', u'portrait')),))], []), (u'@media    screen    and    (color),    projection    and    (color)    {}', [MQ(u'screen', ((u'color', None),)), MQ(u'projection', ((u'color', None),))], []), (u'@media    not    screen    and    (color)    {}', [MQ(u'screen', ((u'color', None),), True)], []), (u'@media    only    screen    and    (color)    {}', [MQ(u'screen', ((u'color', None),))], []), (u'@media    aural    and    (device-aspect-ratio:    16/9)    {}', [MQ(u'aural', ((u'device-aspect-ratio', (u'RATIO', (16, 9))),))], []), (u'@media    (resolution:    166dpi)    {}', [MQ(u'all', ((u'resolution', (u'DIMENSION', 166)),))], []), (u'@media    (min-resolution:    166DPCM)    {}', [MQ(u'all', ((u'min-resolution', (u'DIMENSION', 166)),))], []), (u'@media    (example,    all,),    speech    {}', [MQ(negated=True), MQ(u'speech')], [u'expected    a    :']), (u'@media    &test,    screen    {}', [MQ(negated=True), MQ(u'screen')], [u'expected    a    media    expression    not    a    DELIM'])]:
        stylesheet = CSSMedia3Parser().parse_stylesheet(css)
        self.assert_errors(stylesheet.errors, expected_errors)
        self.ae(len(stylesheet.rules), 1)
        rule = stylesheet.rules[0]
        self.ae(jsonify_expressions(rule.media), media_query_list)
