Sha256: 3d435fae276f27de28d7e89a8c467e409f67eddf942d442d79daf883938f6a4e

Contents?: true

Size: 1.58 KB

Versions: 30

Compression:

Stored size: 1.58 KB

Contents

'''
   Tests for commands module
   Nick Mathewson
'''
import unittest
import os, tempfile, re

from test_support import TestSkipped, run_unittest
from commands import *

# The module says:
#   "NB This only works (and is only relevant) for UNIX."
#
# Actually, getoutput should work on any platform with an os.popen, but
# I'll take the comment as given, and skip this suite.

if os.name != 'posix':
    raise TestSkipped('Not posix; skipping test_commands')


class CommandTests(unittest.TestCase):

    def test_getoutput(self):
        self.assertEquals(getoutput('echo xyzzy'), 'xyzzy')
        self.assertEquals(getstatusoutput('echo xyzzy'), (0, 'xyzzy'))

        # we use mktemp in the next line to get a filename which we
        # _know_ won't exist.  This is guaranteed to fail.
        status, output = getstatusoutput('cat ' + tempfile.mktemp())
        self.assertNotEquals(status, 0)

    def test_getstatus(self):
        # This pattern should match 'ls -ld /.' on any posix
        # system, however perversely configured.
        pat = r'''d.........   # It is a directory.
                  \s+\d+       # It has some number of links.
                  \s+\w+\s+\w+ # It has a user and group, which may
                               #     be named anything.
                  \s+\d+       # It has a size.
                  [^/]*        # Skip the date.
                  /.           # and end with the name of the file.
               '''

        self.assert_(re.match(pat, getstatus("/."), re.VERBOSE))


def test_main():
    run_unittest(CommandTests)


if __name__ == "__main__":
    test_main()

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
rubyfox-server-2.19.2.0 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.17.3.2 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.17.3.1 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.17.3.0 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.16.3.2 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.16.3.1 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.16.0.4 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.16.0.3 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.16.0.2 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.16.0.1 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.16.0.0 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.13.7.3 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.13.6.2 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.13.6.1 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.13.5.1 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.13.4.1 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.13.3.1 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.12.5.1 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.12.5.0 lib/rubyfox/server/data/lib/Lib/test/test_commands.py
rubyfox-server-2.12.4.0 lib/rubyfox/server/data/lib/Lib/test/test_commands.py