Skip to content

Commit 6d89f1e

Browse files
Fix double venv error in tests. Resolve platformio#31 (platformio#46)
* Attempt 1 * Attempt 2 * Attempt 3 * Attempt 4. Move env variable from miniconda to matrix * Attempt 5. Fix conda test * Attempt 6. return commented tests * Attempt 7. fix platform format in penv state * Attempt 8. fix platform * Attempt 9. try use generic for tests * Attempt 10 * Attempt 11 * Attempt 11 * Attempt 11 * Attempt 12 * Attempt 12 * Attempt 13 * Attempt 13 * Attempt 14 * Attempt 15 * Attempt 15 * Attempt 15 * Attempt 15 * Attempt 15 * Attempt 15 * Attempt 15 * Attempt 16 * Attempt 16 * Attempt 17 * Attempt 17 * Attempt 17 * Attempt 18 * Attempt 19 * Fix tests. Resolve platformio#31 Co-authored-by: Ivan Kravets <[email protected]>
1 parent a89558b commit 6d89f1e

File tree

10 files changed

+68
-54
lines changed

10 files changed

+68
-54
lines changed

.appveyor.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ environment:
1313
install:
1414
- cmd: git submodule update --init --recursive
1515
- cmd: SET PATH=C:\MinGW\bin;%PATH%
16-
- cmd: pip install --force-reinstall tox
16+
- cmd: pip install --force-reinstall tox pytest
1717

1818
test_script:
1919
- cmd: tox
20+
- cmd: python --version
21+
- cmd: py.test --verbose --capture=no --exitfirst tests
2022

2123
notifications:
2224
- provider: Slack

.travis.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,39 @@
1-
language: python
1+
language: generic
22

33
matrix:
44
include:
55
- os: linux
6+
dist: bionic
67
sudo: required
7-
python: 2.7
8-
env: TOX_ENV=py27
8+
env:
9+
- TOX_ENV=py27
910
- os: linux
11+
dist: bionic
1012
sudo: required
11-
python: 3.6
12-
env: TOX_ENV=py36
13+
env:
14+
- TOX_ENV=py37
1315
- os: osx
14-
language: generic
15-
env: TOX_ENV=py27
16+
env:
17+
- TOX_ENV=py27
18+
- os: osx
19+
env:
20+
- TOX_ENV=py37
1621

1722
install:
18-
- git submodule update --init --recursive
23+
- if [[ "$TOX_ENV" == "py27" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pyenv global 2.7; fi
24+
- if [[ "$TOX_ENV" == "py37" ]] && [[ "$TRAVIS_OS_NAME" == "linux" ]]; then pyenv global 3.7; fi
25+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$TOX_ENV" == "py27" ]]; then pyenv install 2.7.17; pyenv global 2.7.17; eval "$(pyenv init -)"; fi
26+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]] && [[ "$TOX_ENV" == "py37" ]]; then pyenv install 3.7.5; pyenv global 3.7.5; eval "$(pyenv init -)"; fi
1927
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then curl -fsSL https://bootstrap.pypa.io/get-pip.py | sudo python; fi
20-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O /tmp/miniconda.sh; bash /tmp/miniconda.sh -b -p /tmp/miniconda; export MINICONDA="/tmp/miniconda/python"; else wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh; bash /tmp/miniconda.sh -b -p /tmp/miniconda; export MINICONDA="/tmp/miniconda/python"; fi
21-
- pip install -U tox
28+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then wget https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O /tmp/miniconda.sh; bash /tmp/miniconda.sh -b -p /tmp/miniconda; export MINICONDA="/tmp/miniconda/bin/python"; else wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O /tmp/miniconda.sh; bash /tmp/miniconda.sh -b -p /tmp/miniconda; export MINICONDA="/tmp/miniconda/bin/python"; fi
29+
- python --version
30+
- pip install -U tox pytest
31+
- pip install -e .
2232

2333
script:
34+
- python --version
2435
- tox -e $TOX_ENV
36+
- make test
2537

2638
notifications:
2739
email: false
@@ -30,4 +42,4 @@ notifications:
3042
rooms:
3143
secure: GOUanPMgPnway2tjAblGgoI3FKJD4bM+1fzcpTi4Rutd58WOb9ejgEOTOtfPhrjuUfQt1SP04C5igMQa8o9fagmtI4PUleSC2b8aGivB18gyvMWH4uceHA645+ElulT45SPqkzTYeRsGjrjKD5O1D3JFk6lwFsfzQM5yZ2QSplpMvGG9IvGVfulNzCuSUa66fzzsSRgDWqAfc76s2o6YTF+/gngbxYgwjZp+dGuWOBhEvxEcKXAq4ohSCxPKzTqR87DzS+IMH/nt71hOFZyHRO+5sUDBIxiTyGCIesS9gYVrMgvjCFp8QHWYapj3E3CFaBC5XOE1r/DfNyHfvdqBn6zLwhZPtrflg3dfD8+uPbrwfYRihraUCdI0NiprJGYTSYyduJeg5MqHGD5saTQtpNAMZshxTTse7FcAYT7oYPGf2pxkAGkKfMZb/z3aAIDBQpcUIoWBuZURShFZ1qBmxtVaIiZ9Wm7fLvXXpmINn0xJNeCva57otv4RVWvPj3X5xhCFdshkUeaZndTZPF9RFoCf2FNIR9p4hKqVeBcvpEyMWg/BrczVeLy44NiLgzb8mBx87rU+M9Hxi6OUsCdpAJ4UgHtuQ6XeO0P380KSTDOULdOUuxvPcwoB3QyVxP8lxQNCCH+dFBbeRdQhbu7PYeTmKp0P7/omFiXEGdIycvY=
3244
on_failure: always
33-
on_success: change
45+
on_success: change

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ format:
1010
black --target-version py27 ./tests
1111

1212
test:
13-
py.test --verbose --capture=no --exitfirst -n 1 --dist=loadscope tests
13+
py.test --verbose --capture=no --exitfirst tests
1414

1515
before-commit: isort format lint test
1616

get-platformio.py

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

pioinstaller/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def cli(
4545
ctx.obj["dev"] = dev
4646
if not ctx.invoked_subcommand:
4747
click.echo("Installer version: %s" % __version__)
48-
click.echo("Platform: %s" % platform.platform())
48+
click.echo("Platform: %s" % platform.platform(terse=True))
4949
click.echo("Python version: %s" % sys.version)
5050
click.echo("Python path: %s" % sys.executable)
5151
try:

pioinstaller/core.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import io
1615
import json
1716
import logging
1817
import os
@@ -183,10 +182,10 @@ def check(dev=False, auto_upgrade=False, version_requirements=None):
183182

184183
with open(os.path.join(penv.get_penv_dir(), "state.json")) as fp:
185184
penv_state = json.load(fp)
186-
if penv_state.get("platform") != platform.platform():
185+
if penv_state.get("platform") != platform.platform(terse=True):
187186
raise exception.InvalidPlatformIOCore(
188187
"PlatformIO installed using another platform `%s`. Your platform: %s"
189-
% (penv_state.get("platform"), platform.platform())
188+
% (penv_state.get("platform"), platform.platform(terse=True))
190189
)
191190

192191
try:
@@ -273,5 +272,5 @@ def dump_state(target, state):
273272
if not os.path.isdir(os.path.dirname(target)):
274273
os.makedirs(os.path.dirname(target))
275274

276-
with io.open(target, "w", encoding="utf-8") as fp:
275+
with open(target, "w") as fp:
277276
json.dump(state, fp)

pioinstaller/penv.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def add_state_info(python_exe, penv_dir):
150150
"created_on": int(round(time.time())),
151151
"python": {"path": python_exe, "version": python_version,},
152152
"installer_version": __version__,
153-
"platform": platform.platform(),
153+
"platform": platform.platform(terse=True),
154154
}
155155
with open(os.path.join(penv_dir, "state.json"), "w") as fp:
156156
json.dump(state, fp)

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@
3939
"requests==2.23.0",
4040
"colorama==0.4.3",
4141
"semantic-version==2.8.4",
42-
"certifi==2020.04.05.1"
42+
"certifi==2020.04.05.1",
43+
# Misc
44+
"wheel==0.34.2",
4345
],
4446
packages=find_packages(),
4547
entry_points={

tests/test_core.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -33,35 +33,35 @@ def test_install_pio_core(pio_installer_script, tmpdir, monkeypatch):
3333
)
3434
assert subprocess.check_call([python_exe, "-m", "platformio", "--version"]) == 0
3535

36-
# core_state_path = os.path.join(str(core_dir), "core-state.json")
37-
# assert (
38-
# subprocess.check_call(
39-
# [
40-
# python_exe,
41-
# pio_installer_script,
42-
# "check",
43-
# "core",
44-
# "--dump-state=%s" % core_state_path,
45-
# ]
46-
# )
47-
# == 0
48-
# )
49-
# with open(core_state_path) as fp:
50-
# json_info = json.load(fp)
51-
# assert json_info.get("core_dir") == str(core_dir)
52-
# assert json_info.get("penv_dir") == penv_dir
53-
# assert json_info.get("installer_version") == __version__
54-
# assert json_info.get("system") == util.get_systype()
36+
core_state_path = os.path.join(str(core_dir), "core-state.json")
37+
assert (
38+
subprocess.check_call(
39+
[
40+
"python",
41+
pio_installer_script,
42+
"check",
43+
"core",
44+
"--dump-state=%s" % core_state_path,
45+
]
46+
)
47+
== 0
48+
)
49+
with open(core_state_path) as fp:
50+
json_info = json.load(fp)
51+
assert json_info.get("core_dir") == str(core_dir)
52+
assert json_info.get("penv_dir") == penv_dir
53+
assert json_info.get("installer_version") == __version__
54+
assert json_info.get("system") == util.get_systype()
5555

56-
# assert os.path.isfile(
57-
# os.path.join(
58-
# penv.get_penv_bin_dir(penv_dir),
59-
# "platformio.exe" if util.IS_WINDOWS else "platformio",
60-
# )
61-
# )
62-
# assert os.path.isfile(
63-
# os.path.join(str(core_dir), "packages", "contrib-piohome", "package.json")
64-
# )
65-
# assert os.path.isfile(
66-
# os.path.join(str(core_dir), "packages", "contrib-pysite", "package.json")
67-
# )
56+
assert os.path.isfile(
57+
os.path.join(
58+
penv.get_penv_bin_dir(penv_dir),
59+
"platformio.exe" if util.IS_WINDOWS else "platformio",
60+
)
61+
)
62+
assert os.path.isfile(
63+
os.path.join(str(core_dir), "packages", "contrib-piohome", "package.json")
64+
)
65+
assert os.path.isfile(
66+
os.path.join(str(core_dir), "packages", "contrib-pysite", "package.json")
67+
)

tox.ini

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ deps =
1010
isort
1111
pylint
1212
pytest
13-
pytest-xdist
1413
commands =
1514
{envpython} --version
1615
pioinstaller --version
1716
pylint --rcfile=./.pylintrc ./pioinstaller
18-
py.test --exitfirst tests
17+
# py.test --exitfirst tests

0 commit comments

Comments
 (0)