def test_scanner_none(): """ Ensure overwriting the scanner property works as expected when given proper input as None. """ generator = Generator() generator.scanner = None assert generator.scanner is None, 'Invalid scanner set/retrieved'
def test_encoding_direct(): """ Ensure overwriting the encoding property works as expected when given proper input as the string 'direct'. """ generator = Generator() generator.encoding = 'direct' assert generator.encoding == 'direct', 'Invalid encoding set/retrieved'
def test_filename_valid(): """ Ensure overwriting the filename property works as expected when given proper input as a non empty string. """ generator = Generator() generator.filename = 'foobar' assert generator.filename == 'foobar', 'Invalid filename set/retrieved'
def test_translate_not_implemented(): """ Ensure a NotImplementedError is raised if generation to source language is attempted with the base Generator. """ generator = Generator() generator.scanner = RegularGrammar('test', {'foo': ['b', 'a', 'r']}) generator.parser = ContextFreeGrammar('test', {'S': [['a']]}, 'S') generator.generate()
def test_parser_valid(): """ Ensure overwriting the paser property works as expected when given proper input as a ContextFreeGrammar. """ parser = ContextFreeGrammar('test', {'S': [['a']]}, 'S') generator = Generator() generator.parser = parser assert generator.parser is parser, 'Invalid parser set/retrieved'
def test_scanner_valid(): """ Ensure overwriting the scanner property works as expected when given proper input as a RegularGrammar. """ scanner = RegularGrammar('test', {'foo': 'bar'}) generator = Generator() generator.scanner = scanner assert generator.scanner is scanner, 'Invalid scanner set/retrieved'
def test_constructor(): """ Ensure successful creation of a Generator object. """ generator = Generator() assert generator is not None, 'No Generator produced'