Ejemplo n.º 1
0
 def test_errtable(self):
     """Check if the generated error table is present and complete."""
     source = "jpylib/pgetopt.py"
     errors = y.backquote("sed -n '/^Error/s/ .*//p' " + source)
     errorset = set(errors.split())
     with open(docfile) as f:
         for line in f:
             if line.startswith("| Error"):
                 the_error = line.split()[1]
                 # will raise KeyError if the_error is not in the errorset
                 errorset.remove(the_error)
     self.assertEqual(errorset, set())
Ejemplo n.º 2
0
def do_command(command, source):
    """Run command and print it to stdout.

    Make sure the included text is terminated by a newline. Set the SOURCE
    environment variable to the file from which the "#include !..." command is
    currently being processed. This may be a file included by another.

    """
    os.environ["SOURCE"] = source
    output = y.backquote(command)
    if output.endswith("\n"):
        terminate = ""
    else:
        terminate = "\n"
    print(output, end=terminate)
Ejemplo n.º 3
0
 def getdata(self):
     return json.loads(y.backquote("lib/read-secrets.py"))
Ejemplo n.º 4
0
 def test_isotime(self):
     # Take care to call isotime() roughly at the start of a second, so
     # date(1) will not show a different second.
     time.sleep((1000000 - datetime.datetime.now().microsecond) / 1000000.0)
     self.assertEqual(y.isotime(),
                      y.backquote("date +%Y%m%d:%H%M%S").strip())
Ejemplo n.º 5
0
 def setUp(self):
     sizes = y.backquote("stty size < /dev/tty").split()
     self.rows = int(sizes[0])
     self.cols = int(sizes[1])