コード例 #1
0
ファイル: test_helper.py プロジェクト: keliveshd/SyncSettings
  def test_match_with_folder(self):
    success_cases = [
      Helper.join_path((self.base_path, 'hello', 'foo.txt')),
      Helper.join_path((self.base_path, 'hello', 'world', 'bar.txt')),
      Helper.join_path((self.base_path, 'hello', 'world', 'anything.py')),
      Helper.join_path((self.base_path, 'hello', '.txt')),
      Helper.join_path((self.base_path, 'hello', '.py'))
    ]

    wrong_cases = [
      Helper.join_path((self.base_path, 'hello2', 'foo.txt')),
      Helper.join_path((self.base_path, 'hello2', 'world', 'bar.txt')),
      Helper.join_path((self.base_path, 'hello2', 'world', 'anything.py')),
      Helper.join_path((self.base_path, 'hello2', '.txt')),
      Helper.join_path((self.base_path, 'hello2', '.py'))
    ]

    self.assertFalse(Helper.match_with_folder(self.base_path, self.base_path))

    for s in success_cases:
      self.assertTrue(Helper.match_with_folder(s, Helper.join_path(
        (self.base_path, 'hello')
      )))

    for w in wrong_cases:
      self.assertFalse(Helper.match_with_folder(w, Helper.join_path(
        (self.base_path, 'hello')
      )))
コード例 #2
0
    def test_match_with_folder(self):
        success_cases = [
            Helper.join_path((self.base_path, 'hello', 'foo.txt')),
            Helper.join_path((self.base_path, 'hello', 'world', 'bar.txt')),
            Helper.join_path(
                (self.base_path, 'hello', 'world', 'anything.py')),
            Helper.join_path((self.base_path, 'hello', '.txt')),
            Helper.join_path((self.base_path, 'hello', '.py'))
        ]

        wrong_cases = [
            Helper.join_path((self.base_path, 'hello2', 'foo.txt')),
            Helper.join_path((self.base_path, 'hello2', 'world', 'bar.txt')),
            Helper.join_path(
                (self.base_path, 'hello2', 'world', 'anything.py')),
            Helper.join_path((self.base_path, 'hello2', '.txt')),
            Helper.join_path((self.base_path, 'hello2', '.py'))
        ]

        self.assertFalse(
            Helper.match_with_folder(self.base_path, self.base_path))

        for s in success_cases:
            self.assertTrue(
                Helper.match_with_folder(
                    s, Helper.join_path((self.base_path, 'hello'))))

        for w in wrong_cases:
            self.assertFalse(
                Helper.match_with_folder(
                    w, Helper.join_path((self.base_path, 'hello'))))