Skip to content

TST: show_versions test with unmerged commits #32139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions pandas/tests/util/test_show_versions.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
import re

import pytest

import pandas as pd


@pytest.mark.filterwarnings(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these actually required as part of this change? The linkage here with the rest of the PR isn’t totally clear

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these are just because its annoying to have in the output

# openpyxl
"ignore:defusedxml.lxml is no longer supported:DeprecationWarning"
)
@pytest.mark.filterwarnings(
# html5lib
"ignore:Using or importing the ABCs from:DeprecationWarning"
)
@pytest.mark.filterwarnings(
# fastparquet
"ignore:pandas.core.index is deprecated:FutureWarning"
)
@pytest.mark.filterwarnings(
# pandas_datareader
"ignore:pandas.util.testing is deprecated:FutureWarning"
)
def test_show_versions(capsys):
# gh-32041
pd.show_versions()
Expand Down
27 changes: 12 additions & 15 deletions pandas/util/_print_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,31 @@
import os
import platform
import struct
import subprocess
import sys
from typing import List, Optional, Tuple, Union

from pandas.compat._optional import VERSIONS, _get_version, import_optional_dependency


def _get_commit_hash() -> Optional[str]:
"""
Use vendored versioneer code to get git hash, which handles
git worktree correctly.
"""
from pandas._version import get_versions

versions = get_versions()
return versions["full-revisionid"]


def get_sys_info() -> List[Tuple[str, Optional[Union[str, int]]]]:
"""
Returns system information as a list
"""
blob: List[Tuple[str, Optional[Union[str, int]]]] = []

# get full commit hash
commit = None
if os.path.isdir(".git") and os.path.isdir("pandas"):
try:
pipe = subprocess.Popen(
'git log --format="%H" -n 1'.split(" "),
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
)
so, serr = pipe.communicate()
except (OSError, ValueError):
pass
else:
if pipe.returncode == 0:
commit = so.decode("utf-8").strip().strip('"')
commit = _get_commit_hash()

blob.append(("commit", commit))

Expand Down