Esempio n. 1
0
    def test_expand_path_unix(self):
        """
    Tests the expand_path function. This does not exercise home directory
    expansions since that deals with our environment (that's left to integ
    tests).
    """

        self.assertEqual('', system.expand_path(''))
        self.assertEqual('/tmp', system.expand_path('/tmp'))
        self.assertEqual('/tmp', system.expand_path('/tmp/'))
        self.assertEqual('/tmp', system.expand_path('.', '/tmp'))
        self.assertEqual('/tmp', system.expand_path('./', '/tmp'))
        self.assertEqual('/tmp/foo', system.expand_path('foo', '/tmp'))
        self.assertEqual('/tmp/foo', system.expand_path('./foo', '/tmp'))
Esempio n. 2
0
def getConfigLocation():
    """
  Provides the location of the torrc, raising an IOError with the reason if the
  path can't be determined.
  """

    conn = torTools.getConn()
    configLocation = conn.getInfo("config-file", None)
    torPid, torPrefix = conn.getMyPid(), conn.getPathPrefix()
    if not configLocation: raise IOError("unable to query the torrc location")

    try:
        torCwd = system.get_cwd(torPid)
        return torPrefix + system.expand_path(configLocation, torCwd)
    except IOError, exc:
        raise IOError("querying tor's pwd failed because %s" % exc)
Esempio n. 3
0
  def test_expand_path_windows(self):
    """
    Tests the expand_path function on windows. This does not exercise
    home directory expansions since that deals with our environment
    (that's left to integ tests).
    """

    self.assertEqual('', system.expand_path(''))
    self.assertEqual('C:\\tmp', system.expand_path('C:\\tmp'))
    self.assertEqual('C:\\tmp', system.expand_path('C:\\tmp\\'))
    self.assertEqual('C:\\tmp', system.expand_path('.', 'C:\\tmp'))
    self.assertEqual('C:\\tmp', system.expand_path('.\\', 'C:\\tmp'))
    self.assertEqual('C:\\tmp\\foo', system.expand_path('foo', 'C:\\tmp'))
    self.assertEqual('C:\\tmp\\foo', system.expand_path('.\\foo', 'C:\\tmp'))
Esempio n. 4
0
  def test_expand_path_windows(self):
    """
    Tests the expand_path function on windows. This does not exercise
    home directory expansions since that deals with our environment
    (that's left to integ tests).
    """

    self.assertEquals("", system.expand_path(""))
    self.assertEquals("C:\\tmp", system.expand_path("C:\\tmp"))
    self.assertEquals("C:\\tmp", system.expand_path("C:\\tmp\\"))
    self.assertEquals("C:\\tmp", system.expand_path(".", "C:\\tmp"))
    self.assertEquals("C:\\tmp", system.expand_path(".\\", "C:\\tmp"))
    self.assertEquals("C:\\tmp\\foo", system.expand_path("foo", "C:\\tmp"))
    self.assertEquals("C:\\tmp\\foo", system.expand_path(".\\foo", "C:\\tmp"))
Esempio n. 5
0
  def test_expand_path_unix(self):
    """
    Tests the expand_path function. This does not exercise home directory
    expansions since that deals with our environment (that's left to integ
    tests).
    """

    self.assertEquals("", system.expand_path(""))
    self.assertEquals("/tmp", system.expand_path("/tmp"))
    self.assertEquals("/tmp", system.expand_path("/tmp/"))
    self.assertEquals("/tmp", system.expand_path(".", "/tmp"))
    self.assertEquals("/tmp", system.expand_path("./", "/tmp"))
    self.assertEquals("/tmp/foo", system.expand_path("foo", "/tmp"))
    self.assertEquals("/tmp/foo", system.expand_path("./foo", "/tmp"))
Esempio n. 6
0
    def test_expand_path_unix(self):
        """
    Tests the expand_path function. This does not exercise home directory
    expansions since that deals with our environment (that's left to integ
    tests).
    """

        mocking.mock(platform.system, mocking.return_value("Linux"))
        mocking.mock(os.path.join, posixpath.join, os.path)

        self.assertEquals("", system.expand_path(""))
        self.assertEquals("/tmp", system.expand_path("/tmp"))
        self.assertEquals("/tmp", system.expand_path("/tmp/"))
        self.assertEquals("/tmp", system.expand_path(".", "/tmp"))
        self.assertEquals("/tmp", system.expand_path("./", "/tmp"))
        self.assertEquals("/tmp/foo", system.expand_path("foo", "/tmp"))
        self.assertEquals("/tmp/foo", system.expand_path("./foo", "/tmp"))
Esempio n. 7
0
    def test_expand_path_windows(self):
        """
    Tests the expand_path function on windows. This does not exercise
    home directory expansions since that deals with our environment
    (that's left to integ tests).
    """

        mocking.mock(platform.system, mocking.return_value("Windows"))
        mocking.mock(os.path.join, ntpath.join, os.path)

        self.assertEquals("", system.expand_path(""))
        self.assertEquals("C:\\tmp", system.expand_path("C:\\tmp"))
        self.assertEquals("C:\\tmp", system.expand_path("C:\\tmp\\"))
        self.assertEquals("C:\\tmp", system.expand_path(".", "C:\\tmp"))
        self.assertEquals("C:\\tmp", system.expand_path(".\\", "C:\\tmp"))
        self.assertEquals("C:\\tmp\\foo", system.expand_path("foo", "C:\\tmp"))
        self.assertEquals("C:\\tmp\\foo",
                          system.expand_path(".\\foo", "C:\\tmp"))