Esempio n. 1
0
    def test_git_ignore_parser(self):
        # Test empty file
        self.assertEqual([], parse_git_ignore([]))

        # Test that deep paths are not parsed.
        self.assertEqual([], parse_git_ignore([
            'a/b/c/d/\n',
            '/a/b/c/d/\n',
        ]))

        # Test that top level directories are parsed and comments are ignored.
        self.assertEqual(['a', 'b'],
                         parse_git_ignore([
                             '/a/\n',
                             '/b/\n',
                             '#/c/\n',
                         ]))

        # Test that other patterns are not parsed.
        self.assertEqual([],
                         parse_git_ignore([
                             '/a/*\n',
                             '*.out\n',
                             'b/*.txt\n',
                         ]))

        # Test that files that do not end in a new line are parsed.
        self.assertEqual(['b'], parse_git_ignore([
            '/a/*\n',
            '/b/',
        ]))
Esempio n. 2
0
  def test_git_ignore_parser(self):
    # Test empty file
    self.assertEqual([], parse_git_ignore([]))

    # Test that deep paths are not parsed.
    self.assertEqual([], parse_git_ignore([
        'a/b/c/d/\n',
        '/a/b/c/d/\n',
        ]))

    # Test that top level directories are parsed and comments are ignored.
    self.assertEqual(['a', 'b'], parse_git_ignore([
          '/a/\n',
          '/b/\n',
          '#/c/\n',
          ]))

    # Test that other patterns are not parsed.
    self.assertEqual([], parse_git_ignore([
          '/a/*\n',
          '*.out\n',
          'b/*.txt\n',
          ]))

    # Test that files that do not end in a new line are parsed.
    self.assertEqual(['b'], parse_git_ignore([
          '/a/*\n',
          '/b/',
          ]))
Esempio n. 3
0
  def test_git_ignore_parser(self):
    # Test empty file
    self.assertEqual([], parse_git_ignore([]))

    # Test that deep paths are not parsed.
    self.assertEqual([], parse_git_ignore([
        'a/b/c/d/\n',
        '/a/b/c/d/\n',
        ]))

    # Test that top level directories are parsed and comments are ignored.
    self.assertEqual(['a', 'b'], parse_git_ignore([
          '/a/\n',
          '/b/\n',
          '#/c/\n',
          ]))

    # Test that other patterns are not parsed.
    self.assertEqual([], parse_git_ignore([
          '/a/*\n',
          '*.out\n',
          'b/*.txt\n',
          ]))

    # Test that files that do not end in a new line are parsed.
    self.assertEqual(['b'], parse_git_ignore([
          '/a/*\n',
          '/b/',
          ]))


    # Test the temporary reimplementation of relpath
    # TODO(user): upgrade to a jython including os.relpath
    def test_relpath(self):
      real_getcwd = os.getcwd
      try:
        os.getcwd = lambda: r"/home/user/bar"
        curdir = os.path.split(os.getcwd())[-1]
        self.assertRaises(ValueError, relpath, "")
        self.assertEqual("a", relpath("a"))
        self.assertEqual("a", relpath(posixpath.abspath("a")))
        self.assertEqual("a/b", relpath("a/b"))
        self.assertEqual("../a/b", relpath("../a/b"))
        self.assertEqual("../" + curdir + "/a", relpath("a", "../b"))
        self.assertEqual("../" + curdir + "/a/b", relpath("a/b", "../c"))
        self.assertEqual("../../a", relpath("a", "b/c"))
      finally:
        os.getcwd = real_getcwd