Ejemplo n.º 1
0
 def testBadOption(self):
     o = Arguments()
     realSysErr = sys.stderr
     try:
         sys.stderr = io.StringIO()
         with self.assertRaises(SystemExit) as cm:
             o.parse_args("--fish")
     finally:
         sys.stderr = realSysErr
Ejemplo n.º 2
0
 def testBadSplit(self):
     realSysErr = sys.stderr
     try:
         sys.stderr = io.StringIO()
         o = Arguments()
         with self.assertRaises(SystemExit) as cm:
             o.parse_args(["-f", "bar"])
     finally:
         sys.stderr = realSysErr
Ejemplo n.º 3
0
 def testBadOption(self):
     o = Arguments()
     realSysErr = sys.stderr
     try:
         sys.stderr = io.StringIO()
         with self.assertRaises(SystemExit) as cm:
             o.parse_args("--fish")
     finally:
         sys.stderr = realSysErr
Ejemplo n.º 4
0
 def testBadSplit(self):
     realSysErr = sys.stderr
     try:
         sys.stderr = io.StringIO()
         o = Arguments()
         with self.assertRaises(SystemExit) as cm:
             o.parse_args(["-f", "bar"])
     finally:
         sys.stderr = realSysErr
Ejemplo n.º 5
0
def main(args):
    opts = Arguments()
    try:
        opts.parse_args(args)
    except SystemExit as err:
        print("Error parsing arguments: %s" % ', '.join(args))
        return 1

    userConfig = fractconfig.userConfig()
    t = fractmain.T(userConfig)
Ejemplo n.º 6
0
 def testBasic(self):
     c = self.userConfig
     fm = fractmain.T(c)
     options = Arguments().parse_args(["--save", "foo.png"])
     fm.run(options)
     self.assertTrue(os.path.exists("foo.png"))
     os.remove("foo.png")
Ejemplo n.º 7
0
    def testDefaults(self):
        o = Arguments()
        ns = o.parse_args()
        
        for x in [ns.formula.name, ns.formula.func,
                  ns.inner.name, ns.inner.func, ns.outer.name, ns.outer.func, ns.map]:
            self.assertEqual(None,x)
        
        for flag in [ns.trace, ns.tracez, ns.quit_when_done,
                     ns.explore, ns.nogui]:
            self.assertEqual(False, flag)
            
        self.assertEqual(-1,ns.maxiter)
        self.assertEqual({},ns.paramchanges)
        self.assertEqual([],ns.extra_paths)

        self.assertEqual(None,ns.width)
        self.assertEqual(None,ns.height)
Ejemplo n.º 8
0
    def testBuildOnly(self):
        c = self.userConfig
        fm = fractmain.T(c)
        options = Arguments().parse_args(["--buildonly", "test.so"])

        fm.run(options)
        self.assertTrue(os.path.exists("test.so"))
        os.remove("test.so")
        if os.path.exists("test.so.c"):
            os.remove("test.so.c")
Ejemplo n.º 9
0
    def testDefaults(self):
        o = Arguments()
        ns = o.parse_args()

        for x in [
                ns.formula.name, ns.formula.func, ns.inner.name, ns.inner.func,
                ns.outer.name, ns.outer.func, ns.map
        ]:
            self.assertEqual(None, x)

        for flag in [
                ns.trace, ns.tracez, ns.quit_when_done, ns.explore, ns.nogui
        ]:
            self.assertEqual(False, flag)

        self.assertEqual(-1, ns.maxiter)
        self.assertEqual({}, ns.paramchanges)
        self.assertEqual([], ns.extra_paths)

        self.assertEqual(None, ns.width)
        self.assertEqual(None, ns.height)
Ejemplo n.º 10
0
    def run_nogui(self):
        userConfig = fractconfig.userConfig()
        main = fractmain.T(userConfig)
        times = []
        last_time = now()
        for file in files:
            main.load(file)
            opts = Arguments().parse_args(sys.argv[1:])
            main.run(opts)
            new_time = now()
            times.append(new_time - last_time)

        return times
Ejemplo n.º 11
0
    def testSinglePoint(self):
        c = self.userConfig
        fm = fractmain.T(c)
        options = Arguments().parse_args(["--singlepoint"])

        fm.run(options)
Ejemplo n.º 12
0
    def testHeightWidth(self):
        o = Arguments()
        ns = o.parse_args(["-i", "780", "-j", "445"])

        self.assertEqual(780, ns.width)
        self.assertEqual(445, ns.height)
Ejemplo n.º 13
0
 def testHelp(self):
     o = Arguments()
     help = o.format_help()
     self.assertEqual(1, help.count("To generate an image"))
Ejemplo n.º 14
0
 def testGeneralOptions(self):
     o = Arguments()
     ns = o.parse_args(["-P", "foo", "bar", "-f", "baz/baz.frm#wibble"])
     self.assertEqual(["foo", "bar", "baz"], ns.extra_paths)
     self.assertEqual("baz.frm", ns.formula.name)
     self.assertEqual("wibble", ns.formula.func)
Ejemplo n.º 15
0
 def testHelp(self):
     o = Arguments()
     help = o.format_help()
     self.assertEqual(1, help.count("To generate an image"))
Ejemplo n.º 16
0
 def testGeneralOptions(self):
     o = Arguments()
     ns = o.parse_args(["-P", "foo", "bar", "-f", "baz/baz.frm#wibble"])
     self.assertEqual(["foo", "bar", "baz"],ns.extra_paths)
     self.assertEqual("baz.frm",ns.formula.name)
     self.assertEqual("wibble",ns.formula.func)
Ejemplo n.º 17
0
 def testTransforms(self):
     o = Arguments()
     ns = o.parse_args(["--transforms", "a#b,x#y"])
     self.assertEqual([Formula("", "a","b"), Formula("", "x","y")], ns.transforms)
Ejemplo n.º 18
0
    def testArgument(self):
        o = Arguments()
        ns = o.parse_args(["foo"])

        self.assertEqual("foo", ns.paramfile)
Ejemplo n.º 19
0
    def testArgument(self):
        o = Arguments()
        ns = o.parse_args(["foo"])

        self.assertEqual("foo", ns.paramfile)
Ejemplo n.º 20
0
 def testTransforms(self):
     o = Arguments()
     ns = o.parse_args(["--transforms", "a#b,x#y"])
     self.assertEqual([Formula("", "a", "b"),
                       Formula("", "x", "y")], ns.transforms)
Ejemplo n.º 21
0
    def testHeightWidth(self):
        o = Arguments()
        ns = o.parse_args(["-i", "780", "-j", "445"])

        self.assertEqual(780, ns.width)
        self.assertEqual(445, ns.height)