示例#1
0
 def test_raise_exception(self, _, args, input_image, expected_error):
     with self.assertRaises(expected_error):
         converter = FillHoles(**args)
         if isinstance(input_image,
                       torch.Tensor) and torch.cuda.is_available():
             _ = converter(clone(input_image).cuda())
         else:
             _ = converter(clone(input_image))
示例#2
0
 def test_raise_exception(self, _, args, input_image, expected_error):
     key = CommonKeys.IMAGE
     with self.assertRaises(expected_error):
         converter = FillHolesd(keys=key, **args)
         if isinstance(input_image, torch.Tensor) and torch.cuda.is_available():
             _ = converter({key: clone(input_image).cuda()})[key]
         else:
             _ = converter({key: clone(input_image)})[key]
示例#3
0
    def test_correct_results(self, _, args, input_image, expected):
        converter = KeepLargestConnectedComponent(**args)
        if isinstance(input_image, torch.Tensor) and torch.cuda.is_available():
            result = converter(clone(input_image).cuda())

        else:
            result = converter(clone(input_image))
        assert_allclose(result, expected)
示例#4
0
文件: add_pr.py 项目: 000fan000/code
def setup2repos(proj1, proj2):
    path = proj1.git_real_path
    with clone(path) as workdir:
        with open(join(workdir, 'origin'), 'w') as f:
            f.write('origin')

    path = proj2.git_real_path
    with clone(path) as workdir:
        with open(join(workdir, 'origin'), 'w') as f:
            f.write('modified')
示例#5
0
def setup2repos(proj1, proj2):
    path = proj1.git_real_path
    with clone(path) as workdir:
        with open(join(workdir, 'origin'), 'w') as f:
            f.write('origin')

    path = proj2.git_real_path
    with clone(path) as workdir:
        with open(join(workdir, 'origin'), 'w') as f:
            f.write('modified')
示例#6
0
    def create_project_and_a_fork(self):
        from nose import SkipTest
        raise SkipTest(
            "These tests have Segmentation Fault")  # guibog 20121105
        orig = CodeDoubanProject.add('orig', 'origuser')
        with clone(orig.git_real_path) as workdir:
            with open(os.path.join(workdir, 'a'), 'w') as f:
                f.write("a line of code\n")

        fork = orig.fork('fork', 'forkuser')
        with clone(fork.git_real_path) as workdir:
            with open(os.path.join(workdir, 'b'), 'w') as f:
                f.write("another line of code\n")

        return orig, fork
示例#7
0
    def test_conflict_detection(self):
        """有冲突存在时,is_auto_mergable()应返回False"""
        with mkdtemp() as tmpdir:
            path, repo, fork_path, fork_repo = setup_repos(
                tmpdir, 'test_conflict_detection')

            # make conflict changes

            with clone(path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("asdf")

            with clone(fork_path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("fdsa")

            # submit a pull request

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            assert not pullreq.is_auto_mergable()
            # assure merge --abort
            assert not os.path.exists(os.path.join(path, 'MERGE_MODE'))
示例#8
0
    def test_conflict_detection(self):
        """有冲突存在时,is_auto_mergable()应返回False"""
        with mkdtemp() as tmpdir:
            path, repo, fork_path, fork_repo = setup_repos(
                tmpdir, 'test_conflict_detection')

            # make conflict changes

            with clone(path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("asdf")

            with clone(fork_path) as work_path:
                with open(join(work_path, 'a'), 'w') as f:
                    f.write("fdsa")

            # submit a pull request

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            assert not pullreq.is_auto_mergable()
            # assure merge --abort
            assert not os.path.exists(os.path.join(path, 'MERGE_MODE'))
示例#9
0
    def test_get_diffs(self):
        """应该能够得到所有将合并的diff"""
        with setup2repos('prj4') as (path, repo, fork_path, fork_repo):

            # make some change in origin repo, too
            with clone(path) as work_path:
                with chdir(work_path):
                    with open('b', 'w') as f:
                        f.write('b')

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            diffs = pullreq.get_diff()
            # should not contain file b in origin
            eq_(diffs.length, 1)
示例#10
0
    def test_get_diffs(self):
        """应该能够得到所有将合并的diff"""
        with setup2repos('prj4') as (path, repo, fork_path, fork_repo):

            # make some change in origin repo, too
            with clone(path) as work_path:
                with chdir(work_path):
                    with open('b', 'w') as f:
                        f.write('b')

            pullreq = PullRequest.open(fork_repo, 'master', repo, 'master')
            diffs = pullreq.get_diff()
            # should not contain file b in origin
            eq_(diffs.length, 1)
示例#11
0
 def test_correct_results(self, _, args, input_image, expected):
     converter = FillHoles(**args)
     for p in TEST_NDARRAYS:
         result = converter(p(clone(input_image)))
         assert_allclose(result, p(expected))
示例#12
0
 def test_correct_results(self, _, args, input_image, expected):
     key = CommonKeys.IMAGE
     converter = FillHolesd(keys=key, **args)
     for p in TEST_NDARRAYS:
         result = converter({key: p(clone(input_image))})[key]
         assert_allclose(result, p(expected), type_test="tensor")