Example #1
0
    def testAddMethod(self):

        # needs world bounds checking for world smaller than pattern

        for pattern in Patterns.values():

            world = World(width=40, height=40)

            nAlivePatternCells = len([c for c in pattern if not c.isspace()])

            world.addPattern(pattern)

            self.assertEqual(len([cell for cell in world if cell.alive]),
                             nAlivePatternCells,
                             'pattern {pattern}'.format(pattern=pattern))

        for name, pattern in Patterns.items():

            world = World(width=40, height=40)

            nAlivePatternCells = len([c for c in pattern if not c.isspace()])

            world.addPattern(name)

            self.assertEqual(len([cell for cell in world if cell.alive]),
                             nAlivePatternCells,
                             'pattern {pattern}'.format(pattern=pattern))
Example #2
0
    def testAddMethod(self):

        # needs world bounds checking for world smaller than pattern

        for pattern in list(Patterns.values()):

            world = World(width=40, height=40)

            nAlivePatternCells = len([c for c in pattern if not c.isspace()])

            world.addPattern(pattern)

            self.assertEqual(len([cell for cell in world if cell.alive]),
                             nAlivePatternCells,
                             'pattern {pattern}'.format(pattern=pattern))

        for name, pattern in list(Patterns.items()):

            world = World(width=40, height=40)

            nAlivePatternCells = len([c for c in pattern if not c.isspace()])

            world.addPattern(name)

            self.assertEqual(len([cell for cell in world if cell.alive]),
                             nAlivePatternCells,
                             'pattern {pattern}'.format(pattern=pattern))
Example #3
0
def usage(argv,msg=None,exit_value=-1):
    usagefmt = 'usage: {name} [[pattern_name],[X,Y]] ...'
    namefmt = '\t{n}'
    print(usagefmt.format(name=os.path.basename(argv[0])))
    if msg:
        print(msg)
    print('pattern names:')
    [print(namefmt.format(n=name)) for name in Patterns.keys()]
    exit(exit_value)
Example #4
0
def usage(argv, msg=None, exit_value=-1):
    usagefmt = 'usage: {name} [[pattern_name],[X,Y]] ...'
    namefmt = '\t{n}'
    print(usagefmt.format(name=os.path.basename(argv[0])))
    if msg:
        print(msg)
    print('pattern names:')
    [print(namefmt.format(n=name)) for name in Patterns.keys()]
    exit(exit_value)