예제 #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
파일: add_pr.py 프로젝트: jackfrued/code-1
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")