コード例 #1
0
ファイル: test_main.py プロジェクト: hynek/doc2dash
    def test_detects_existing_dest(self, tmpdir, monkeypatch):
        """
        Exit with EEXIST if the selected destination already exists.
        """
        monkeypatch.chdir(tmpdir)
        os.mkdir("foo")
        os.mkdir("foo.docset")
        with pytest.raises(SystemExit) as e:
            main.setup_paths(
                source="foo",
                force=False,
                name=None,
                destination=None,
                add_to_global=False,
            )
        assert e.value.code == errno.EEXIST

        main.setup_paths(
            source="foo",
            force=True,
            name=None,
            destination=None,
            add_to_global=False,
        )
        assert not os.path.lexists("foo.docset")
コード例 #2
0
    def test_detects_existing_dest(self, tmpdir, monkeypatch):
        """
        Exit with EEXIST if the selected destination already exists.
        """
        monkeypatch.chdir(tmpdir)
        os.mkdir("foo")
        os.mkdir("foo.docset")
        with pytest.raises(SystemExit) as e:
            main.setup_paths(
                source="foo",
                force=False,
                name=None,
                destination=None,
                add_to_global=False,
            )
        assert e.value.code == errno.EEXIST

        main.setup_paths(
            source="foo",
            force=True,
            name=None,
            destination=None,
            add_to_global=False,
        )
        assert not os.path.lexists("foo.docset")
コード例 #3
0
ファイル: test_main.py プロジェクト: asheraScout/doc2dash
 def test_works(self, tmpdir):
     """
     Integration tests with fake paths.
     """
     foo_path = str(tmpdir.join('foo'))
     os.mkdir(foo_path)
     assert (
         (foo_path, str(tmpdir.join('foo.docset')), "foo")
         == main.setup_paths(
             foo_path, str(tmpdir), name=None, add_to_global=False,
             force=False
         )
     )
     abs_foo = os.path.abspath(foo_path)
     assert (
         (abs_foo, str(tmpdir.join('foo.docset')), "foo") ==
         main.setup_paths(
             abs_foo, str(tmpdir), name=None, add_to_global=False,
             force=False
         )
     )
     assert (
         (abs_foo, str(tmpdir.join('baz.docset')), "baz") ==
         main.setup_paths(
             abs_foo, str(tmpdir), name="baz", add_to_global=False,
             force=False
         )
     )
コード例 #4
0
 def test_works(self, tmpdir):
     """
     Integration tests with fake paths.
     """
     foo_path = str(tmpdir.join('foo'))
     os.mkdir(foo_path)
     assert ((foo_path, str(tmpdir.join('foo.docset')),
              "foo") == main.setup_paths(foo_path,
                                         str(tmpdir),
                                         name=None,
                                         add_to_global=False,
                                         force=False))
     abs_foo = os.path.abspath(foo_path)
     assert ((abs_foo, str(tmpdir.join('foo.docset')),
              "foo") == main.setup_paths(abs_foo,
                                         str(tmpdir),
                                         name=None,
                                         add_to_global=False,
                                         force=False))
     assert ((abs_foo, str(tmpdir.join('baz.docset')),
              "baz") == main.setup_paths(abs_foo,
                                         str(tmpdir),
                                         name="baz",
                                         add_to_global=False,
                                         force=False))
コード例 #5
0
 def test_detects_source_is_file(self, args):
     """
     Exit with ENOTDIR if a file is passed as source.
     """
     args.configure_mock(source='setup.py', name=None)
     with pytest.raises(SystemExit) as e:
         main.setup_paths(args)
     assert e.value.code == errno.ENOTDIR
コード例 #6
0
 def test_detects_missing_source(self, args):
     """
     Exit wie ENOENT if source doesn't exist.
     """
     args.configure_mock(source='doesnotexist', name=None)
     with pytest.raises(SystemExit) as e:
         main.setup_paths(args)
     assert e.value.code == errno.ENOENT
コード例 #7
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def test_detects_source_is_file(self, args):
     """
     Exit with ENOTDIR if a file is passed as source.
     """
     args.configure_mock(source='setup.py', name=None)
     with pytest.raises(SystemExit) as e:
         main.setup_paths(args)
     assert e.value.code == errno.ENOTDIR
コード例 #8
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def test_detects_missing_source(self, args):
     """
     Exit wie ENOENT if source doesn't exist.
     """
     args.configure_mock(source='doesnotexist', name=None)
     with pytest.raises(SystemExit) as e:
         main.setup_paths(args)
     assert e.value.code == errno.ENOENT
コード例 #9
0
def test_setup_paths_detects_existing_dest(monkeypatch):
    with tempfile.TemporaryDirectory() as td:
        monkeypatch.chdir(td)
        os.mkdir('foo')
        os.mkdir('foo.docset')
        args.configure_mock(source='foo', force=False, name=None,
                            destination=None, A=False)
        with pytest.raises(SystemExit) as e:
            main.setup_paths(args)
        assert e.value.code == errno.EEXIST

        args.force = True
        main.setup_paths(args)
        assert not os.path.lexists('foo.docset')
コード例 #10
0
ファイル: test_main.py プロジェクト: ofan/doc2dash
def test_setup_paths_detects_existing_dest(monkeypatch):
    with tempfile.TemporaryDirectory() as td:
        monkeypatch.chdir(td)
        os.mkdir('foo')
        os.mkdir('foo.docset')
        args.configure_mock(source='foo', force=False, name=None,
                            destination=None, A=False)
        with pytest.raises(SystemExit) as e:
            main.setup_paths(args)
        assert e.value.code == errno.EEXIST

        args.force = True
        main.setup_paths(args)
        assert not os.path.lexists('foo.docset')
コード例 #11
0
ファイル: test_main.py プロジェクト: ofan/doc2dash
def test_setup_paths_works(monkeypatch):
    with tempfile.TemporaryDirectory() as td:
        foo_path = os.path.join(td, 'foo')
        os.mkdir(foo_path)
        args.configure_mock(source=foo_path, name=None, destination=td)
        assert ((foo_path, os.path.join(td, 'foo.docset')) ==
                main.setup_paths(args))
        abs_foo = os.path.abspath(foo_path)
        args.source = abs_foo
        assert ((abs_foo, os.path.join(td, 'foo.docset')) ==
                main.setup_paths(args))
        assert args.name == 'foo'
        args.name = 'baz.docset'
        assert ((abs_foo, os.path.join(td, 'baz.docset')) ==
                main.setup_paths(args))
        assert args.name == 'baz'
コード例 #12
0
def test_setup_paths_works(monkeypatch):
    with tempfile.TemporaryDirectory() as td:
        foo_path = os.path.join(td, 'foo')
        os.mkdir(foo_path)
        args.configure_mock(source=foo_path, name=None, destination=td)
        assert ((foo_path, os.path.join(td, 'foo.docset')) ==
                main.setup_paths(args))
        abs_foo = os.path.abspath(foo_path)
        args.source = abs_foo
        assert ((abs_foo, os.path.join(td, 'foo.docset')) ==
                main.setup_paths(args))
        assert args.name == 'foo'
        args.name = 'baz.docset'
        assert ((abs_foo, os.path.join(td, 'baz.docset')) ==
                main.setup_paths(args))
        assert args.name == 'baz'
コード例 #13
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
    def test_detects_existing_dest(self, args, tmpdir, monkeypatch):
        """
        Exit with EEXIST if the selected destination already exists.
        """
        monkeypatch.chdir(tmpdir)
        os.mkdir('foo')
        os.mkdir('foo.docset')
        args.configure_mock(source='foo', force=False, name=None,
                            destination=None, A=False)
        with pytest.raises(SystemExit) as e:
            main.setup_paths(args)
        assert e.value.code == errno.EEXIST

        args.force = True
        main.setup_paths(args)
        assert not os.path.lexists('foo.docset')
コード例 #14
0
ファイル: test_main.py プロジェクト: uxawseny/doc2dash
 def test_cleans_name(self, tmpdir):
     """
     If the name ends with .docset, remove it.
     """
     d = tmpdir.mkdir("foo")
     assert "baz" == main.setup_paths(
         source=str(d), force=False, name="baz.docset", destination="bar",
         add_to_global=False,
     )[2]
コード例 #15
0
ファイル: test_main.py プロジェクト: uxawseny/doc2dash
 def test_deducts_name_with_trailing_slash(self, tmpdir, monkeypatch):
     """
     If the source path ends with a /, the name is still correctly deducted.
     """
     monkeypatch.chdir(tmpdir)
     os.mkdir('foo')
     assert "foo" == main.setup_paths(
         source='foo/', force=False, name=None,
         destination=None, add_to_global=False)[0]
コード例 #16
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def test_A_overrides_destination(self, args, monkeypatch):
     """
     Passing A computes the destination and overrides an argument.
     """
     assert '~' not in main.DEFAULT_DOCSET_PATH  # resolved?
     args.configure_mock(source='doc2dash', name=None, destination='foobar',
                         A=True)
     assert ('foo', os.path.join(main.DEFAULT_DOCSET_PATH, 'foo.docset') ==
             main.setup_paths(args))
コード例 #17
0
ファイル: test_main.py プロジェクト: asheraScout/doc2dash
 def test_cleans_name(self, tmpdir):
     """
     If the name ends with .docset, remove it.
     """
     d = tmpdir.mkdir("foo")
     assert "baz" == main.setup_paths(
         source=str(d), force=False, name="baz.docset", destination="bar",
         add_to_global=False,
     )[2]
コード例 #18
0
ファイル: test_main.py プロジェクト: asheraScout/doc2dash
 def test_deducts_name_with_trailing_slash(self, tmpdir, monkeypatch):
     """
     If the source path ends with a /, the name is still correctly deducted.
     """
     monkeypatch.chdir(tmpdir)
     os.mkdir('foo')
     assert "foo" == main.setup_paths(
         source='foo/', force=False, name=None,
         destination=None, add_to_global=False)[0]
コード例 #19
0
    def test_detects_existing_dest(self, args, tmpdir, monkeypatch):
        """
        Exit with EEXIST if the selected destination already exists.
        """
        monkeypatch.chdir(tmpdir)
        os.mkdir('foo')
        os.mkdir('foo.docset')
        args.configure_mock(source='foo',
                            force=False,
                            name=None,
                            destination=None,
                            A=False)
        with pytest.raises(SystemExit) as e:
            main.setup_paths(args)
        assert e.value.code == errno.EEXIST

        args.force = True
        main.setup_paths(args)
        assert not os.path.lexists('foo.docset')
コード例 #20
0
 def test_works(self, args, monkeypatch, tmpdir):
     """
     Integration test with mocked-out parser.
     """
     foo_path = str(tmpdir.join('foo'))
     os.mkdir(foo_path)
     args.configure_mock(source=foo_path,
                         name=None,
                         destination=str(tmpdir))
     assert ((foo_path,
              str(tmpdir.join('foo.docset'))) == main.setup_paths(args))
     abs_foo = os.path.abspath(foo_path)
     args.source = abs_foo
     assert ((abs_foo,
              str(tmpdir.join('foo.docset')) == main.setup_paths(args)))
     assert args.name == 'foo'
     args.name = 'baz.docset'
     assert ((abs_foo,
              str(tmpdir.join('baz.docset')) == main.setup_paths(args)))
     assert args.name == 'baz'
コード例 #21
0
 def test_A_overrides_destination(self, args, monkeypatch):
     """
     Passing A computes the destination and overrides an argument.
     """
     assert '~' not in main.DEFAULT_DOCSET_PATH  # resolved?
     args.configure_mock(source='doc2dash',
                         name=None,
                         destination='foobar',
                         A=True)
     assert ('foo', os.path.join(main.DEFAULT_DOCSET_PATH,
                                 'foo.docset') == main.setup_paths(args))
コード例 #22
0
ファイル: test_main.py プロジェクト: asheraScout/doc2dash
 def test_add_to_global_overrides_destination(self):
     """
     Passing -A computes the destination and overrides an argument.
     """
     assert "~" not in main.DEFAULT_DOCSET_PATH  # resolved?
     assert (
         "foo", os.path.join(main.DEFAULT_DOCSET_PATH, "foo.docset"), "foo"
     ) == main.setup_paths(
         source="foo", name=None, destination="foobar",
         add_to_global=True, force=False
     )
コード例 #23
0
ファイル: test_main.py プロジェクト: uxawseny/doc2dash
 def test_add_to_global_overrides_destination(self):
     """
     Passing -A computes the destination and overrides an argument.
     """
     assert "~" not in main.DEFAULT_DOCSET_PATH  # resolved?
     assert (
         "foo", os.path.join(main.DEFAULT_DOCSET_PATH, "foo.docset"), "foo"
     ) == main.setup_paths(
         source="foo", name=None, destination="foobar",
         add_to_global=True, force=False
     )
コード例 #24
0
 def test_A_overrides_destination(self):
     """
     Passing A computes the destination and overrides an argument.
     """
     assert '~' not in main.DEFAULT_DOCSET_PATH  # resolved?
     assert ('foo', os.path.join(main.DEFAULT_DOCSET_PATH, 'foo.docset'),
             "foo" == main.setup_paths(source='doc2dash',
                                       name=None,
                                       destination='foobar',
                                       add_to_global=True,
                                       force=False))
コード例 #25
0
ファイル: test_main.py プロジェクト: hawkowl/doc2dash
 def test_A_overrides_destination(self):
     """
     Passing A computes the destination and overrides an argument.
     """
     assert '~' not in main.DEFAULT_DOCSET_PATH  # resolved?
     assert (
         'foo', os.path.join(main.DEFAULT_DOCSET_PATH, 'foo.docset'), "foo"
         == main.setup_paths(
             source='doc2dash', name=None, destination='foobar',
             add_to_global=True, force=False
         )
     )
コード例 #26
0
ファイル: allPythonContent.py プロジェクト: Mondego/pyreco
 def test_works(self, args, monkeypatch, tmpdir):
     """
     Integration test with mocked-out parser.
     """
     foo_path = str(tmpdir.join('foo'))
     os.mkdir(foo_path)
     args.configure_mock(
         source=foo_path, name=None, destination=str(tmpdir)
     )
     assert (
         (foo_path, str(tmpdir.join('foo.docset')))
         == main.setup_paths(args)
     )
     abs_foo = os.path.abspath(foo_path)
     args.source = abs_foo
     assert ((abs_foo, str(tmpdir.join('foo.docset')) ==
             main.setup_paths(args)))
     assert args.name == 'foo'
     args.name = 'baz.docset'
     assert ((abs_foo, str(tmpdir.join('baz.docset')) ==
             main.setup_paths(args)))
     assert args.name == 'baz'
コード例 #27
0
ファイル: test_main.py プロジェクト: ofan/doc2dash
def test_setup_paths_detects_source_is_file():
    args.configure_mock(source='setup.py', name=None)
    with pytest.raises(SystemExit) as e:
        main.setup_paths(args)
    assert e.value.code == errno.ENOTDIR
コード例 #28
0
ファイル: test_main.py プロジェクト: ofan/doc2dash
def test_setup_paths_detects_missing_source():
    args.configure_mock(source='doesnotexist', name=None)
    with pytest.raises(SystemExit) as e:
        main.setup_paths(args)
    assert e.value.code == errno.ENOENT
コード例 #29
0
ファイル: test_main.py プロジェクト: ofan/doc2dash
def test_A_overrides_destination(monkeypatch):
    assert '~' not in main.DEFAULT_DOCSET_PATH  # resolved?
    args.configure_mock(source='doc2dash', name=None, destination='foobar',
                        A=True)
    assert ('foo', os.path.join(main.DEFAULT_DOCSET_PATH, 'foo.docset') ==
            main.setup_paths(args))
コード例 #30
0
def test_A_overrides_destination(monkeypatch):
    assert '~' not in main.DEFAULT_DOCSET_PATH  # resolved?
    args.configure_mock(source='doc2dash', name=None, destination='foobar',
                        A=True)
    assert ('foo', os.path.join(main.DEFAULT_DOCSET_PATH, 'foo.docset') ==
            main.setup_paths(args))
コード例 #31
0
def test_setup_paths_detects_missing_source():
    args.configure_mock(source='doesnotexist', name=None)
    with pytest.raises(SystemExit) as e:
        main.setup_paths(args)
    assert e.value.code == errno.ENOENT
コード例 #32
0
def test_setup_paths_detects_source_is_file():
    args.configure_mock(source='setup.py', name=None)
    with pytest.raises(SystemExit) as e:
        main.setup_paths(args)
    assert e.value.code == errno.ENOTDIR