Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
python-poetry
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
python-poetry
Commits
6c3d357a
Unverified
Commit
6c3d357a
authored
Dec 24, 2019
by
Sébastien Eustace
Committed by
GitHub
Dec 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up tests (#1785)
parent
db6db8f8
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
93 additions
and
101 deletions
+93
-101
.github/workflows/main.yml
+21
-3
poetry/utils/helpers.py
+6
-0
tests/conftest.py
+2
-49
tests/console/conftest.py
+2
-49
tests/fixtures/with_local_config/poetry.toml
+1
-0
tests/helpers.py
+61
-0
No files found.
.github/workflows/main.yml
View file @
6c3d357a
...
...
@@ -30,10 +30,16 @@ jobs:
uses
:
actions/setup-python@v1
with
:
python-version
:
${{ matrix.python-version }}
-
name
:
Install Poetry
-
name
:
Install
and set up
Poetry
run
:
|
python get-poetry.py --preview -y
source $HOME/.poetry/env
poetry config virtualenvs.in-project true
-
name
:
Set up cache
uses
:
actions/cache@v1
with
:
path
:
.venv
key
:
${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
-
name
:
Install dependencies
run
:
|
source $HOME/.poetry/env
...
...
@@ -56,10 +62,16 @@ jobs:
uses
:
actions/setup-python@v1
with
:
python-version
:
${{ matrix.python-version }}
-
name
:
Install Poetry
-
name
:
Install
and set up
Poetry
run
:
|
python get-poetry.py --preview -y
source $HOME/.poetry/env
poetry config virtualenvs.in-project true
-
name
:
Set up cache
uses
:
actions/cache@v1
with
:
path
:
.venv
key
:
${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
-
name
:
Install dependencies
run
:
|
source $HOME/.poetry/env
...
...
@@ -82,10 +94,16 @@ jobs:
uses
:
actions/setup-python@v1
with
:
python-version
:
${{ matrix.python-version }}
-
name
:
Install Poetry
-
name
:
Install
and setup
Poetry
run
:
|
python get-poetry.py --preview -y
$env:Path += ";$env:Userprofile\.poetry\bin"
poetry config virtualenvs.in-project true
-
name
:
Set up cache
uses
:
actions/cache@v1
with
:
path
:
.venv
key
:
${{ runner.os }}-venv-${{ matrix.python-version }}-${{ hashFiles('**/poetry.lock') }}
-
name
:
Install dependencies
run
:
|
$env:Path += ";$env:Userprofile\.poetry\bin"
...
...
poetry/utils/helpers.py
View file @
6c3d357a
...
...
@@ -159,11 +159,17 @@ def get_client_cert(config, repository_name): # type: (Config, str) -> Optional
def
_on_rm_error
(
func
,
path
,
exc_info
):
if
not
os
.
path
.
exists
(
path
):
return
os
.
chmod
(
path
,
stat
.
S_IWRITE
)
func
(
path
)
def
safe_rmtree
(
path
):
if
Path
(
path
)
.
is_symlink
():
return
os
.
unlink
(
str
(
path
))
shutil
.
rmtree
(
path
,
onerror
=
_on_rm_error
)
...
...
tests/conftest.py
View file @
6c3d357a
...
...
@@ -10,15 +10,9 @@ import pytest
from
poetry.config.config
import
Config
as
BaseConfig
from
poetry.config.dict_config_source
import
DictConfigSource
from
poetry.utils._compat
import
PY2
from
poetry.utils._compat
import
WINDOWS
from
poetry.utils._compat
import
Path
try
:
import
urllib.parse
as
urlparse
except
ImportError
:
import
urlparse
from
tests.helpers
import
mock_clone
from
tests.helpers
import
mock_download
class
Config
(
BaseConfig
):
...
...
@@ -69,47 +63,6 @@ def config(config_source, auth_config_source, mocker):
return
c
def
mock_clone
(
_
,
source
,
dest
):
# Checking source to determine which folder we need to copy
parts
=
urlparse
.
urlparse
(
source
)
folder
=
(
Path
(
__file__
)
.
parent
/
"fixtures"
/
"git"
/
parts
.
netloc
/
parts
.
path
.
lstrip
(
"/"
)
.
rstrip
(
".git"
)
)
if
dest
.
exists
():
shutil
.
rmtree
(
str
(
dest
))
shutil
.
copytree
(
str
(
folder
),
str
(
dest
))
def
mock_download
(
self
,
url
,
dest
):
parts
=
urlparse
.
urlparse
(
url
)
fixtures
=
Path
(
__file__
)
.
parent
/
"fixtures"
fixture
=
fixtures
/
parts
.
path
.
lstrip
(
"/"
)
if
dest
.
exists
():
os
.
unlink
(
str
(
dest
))
# Python2 does not support os.symlink on Windows whereas Python3 does. os.symlink requires either administrative
# privileges or developer mode on Win10, throwing an OSError is neither is active.
if
WINDOWS
:
if
PY2
:
shutil
.
copyfile
(
str
(
fixture
),
str
(
dest
))
else
:
try
:
os
.
symlink
(
str
(
fixture
),
str
(
dest
))
except
OSError
:
shutil
.
copyfile
(
str
(
fixture
),
str
(
dest
))
else
:
os
.
symlink
(
str
(
fixture
),
str
(
dest
))
@pytest.fixture
(
autouse
=
True
)
def
download_mock
(
mocker
):
# Patch download to not download anything but to just copy from fixtures
...
...
tests/console/conftest.py
View file @
6c3d357a
import
os
import
shutil
import
pytest
...
...
@@ -13,17 +12,10 @@ from poetry.poetry import Poetry as BasePoetry
from
poetry.repositories
import
Pool
from
poetry.repositories
import
Repository
as
BaseRepository
from
poetry.repositories.exceptions
import
PackageNotFound
from
poetry.utils._compat
import
PY2
from
poetry.utils._compat
import
WINDOWS
from
poetry.utils._compat
import
Path
from
poetry.utils.toml_file
import
TomlFile
from
poetry.vcs.git
import
ParsedUrl
try
:
import
urllib.parse
as
urlparse
except
ImportError
:
import
urlparse
from
tests.helpers
import
mock_clone
from
tests.helpers
import
mock_download
@pytest.fixture
()
...
...
@@ -31,45 +23,6 @@ def installer():
return
NoopInstaller
()
def
mock_clone
(
self
,
source
,
dest
):
# Checking source to determine which folder we need to copy
parsed
=
ParsedUrl
.
parse
(
source
)
folder
=
(
Path
(
__file__
)
.
parent
.
parent
/
"fixtures"
/
"git"
/
parsed
.
resource
/
parsed
.
pathname
.
lstrip
(
"/"
)
.
rstrip
(
".git"
)
)
shutil
.
rmtree
(
str
(
dest
))
shutil
.
copytree
(
str
(
folder
),
str
(
dest
))
def
mock_download
(
self
,
url
,
dest
):
parts
=
urlparse
.
urlparse
(
url
)
fixtures
=
Path
(
__file__
)
.
parent
.
parent
/
"fixtures"
fixture
=
fixtures
/
parts
.
path
.
lstrip
(
"/"
)
if
dest
.
exists
():
shutil
.
rmtree
(
str
(
dest
))
# Python2 does not support os.symlink on Windows whereas Python3 does. os.symlink requires either administrative
# privileges or developer mode on Win10, throwing an OSError is neither is active.
if
WINDOWS
:
if
PY2
:
shutil
.
copyfile
(
str
(
fixture
),
str
(
dest
))
else
:
try
:
os
.
symlink
(
str
(
fixture
),
str
(
dest
))
except
OSError
:
shutil
.
copyfile
(
str
(
fixture
),
str
(
dest
))
else
:
os
.
symlink
(
str
(
fixture
),
str
(
dest
))
@pytest.fixture
def
installed
():
return
BaseRepository
()
...
...
tests/fixtures/with_local_config/poetry.toml
View file @
6c3d357a
[virtualenvs]
in-project
=
false
create
=
false
tests/helpers.py
View file @
6c3d357a
import
os
import
shutil
from
poetry.packages
import
Dependency
from
poetry.packages
import
Package
from
poetry.utils._compat
import
PY2
from
poetry.utils._compat
import
WINDOWS
from
poetry.utils._compat
import
Path
from
poetry.utils._compat
import
urlparse
from
poetry.vcs.git
import
ParsedUrl
FIXTURE_PATH
=
Path
(
__file__
)
.
parent
/
"fixtures"
...
...
@@ -27,3 +34,57 @@ def fixture(path=None):
return
FIXTURE_PATH
/
path
else
:
return
FIXTURE_PATH
def
copy_or_symlink
(
source
,
dest
):
if
dest
.
exists
():
if
dest
.
is_symlink
():
os
.
unlink
(
str
(
dest
))
elif
dest
.
is_dir
():
shutil
.
rmtree
(
str
(
dest
))
else
:
os
.
unlink
(
str
(
dest
))
# Python2 does not support os.symlink on Windows whereas Python3 does.
# os.symlink requires either administrative privileges or developer mode on Win10,
# throwing an OSError if neither is active.
if
WINDOWS
:
if
PY2
:
if
source
.
is_dir
():
shutil
.
copytree
(
str
(
source
),
str
(
dest
))
else
:
shutil
.
copyfile
(
str
(
source
),
str
(
dest
))
else
:
try
:
os
.
symlink
(
str
(
source
),
str
(
dest
),
target_is_directory
=
source
.
is_dir
())
except
OSError
:
if
source
.
is_dir
():
shutil
.
copytree
(
str
(
source
),
str
(
dest
))
else
:
shutil
.
copyfile
(
str
(
source
),
str
(
dest
))
else
:
os
.
symlink
(
str
(
source
),
str
(
dest
))
def
mock_clone
(
_
,
source
,
dest
):
# Checking source to determine which folder we need to copy
parsed
=
ParsedUrl
.
parse
(
source
)
folder
=
(
Path
(
__file__
)
.
parent
/
"fixtures"
/
"git"
/
parsed
.
resource
/
parsed
.
pathname
.
lstrip
(
"/"
)
.
rstrip
(
".git"
)
)
copy_or_symlink
(
folder
,
dest
)
def
mock_download
(
self
,
url
,
dest
):
parts
=
urlparse
.
urlparse
(
url
)
fixtures
=
Path
(
__file__
)
.
parent
/
"fixtures"
fixture
=
fixtures
/
parts
.
path
.
lstrip
(
"/"
)
copy_or_symlink
(
fixture
,
dest
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment