-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65aca13
commit d8257fd
Showing
8 changed files
with
177 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"""tests for python code. any tests for typescript code should go in | ||
`packages/pyright-internal/src/tests` instead""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
""" | ||
these tests assume that the doc stubs have already run (they should get run as part of | ||
`pdm install`) as they validate that the current state of the `docstubs` folder is correct | ||
""" | ||
|
||
from __future__ import annotations | ||
|
||
import sys | ||
from locale import getpreferredencoding | ||
from pathlib import Path | ||
|
||
from pytest import mark | ||
|
||
quotes = '"""' | ||
|
||
|
||
def read_module_text(name: str): | ||
return Path("docstubs/stdlib", name).read_text( | ||
encoding=getpreferredencoding(do_setlocale=False) | ||
) | ||
|
||
|
||
def test_builtin_docstring(): | ||
assert ''' | ||
class float: | ||
"""Convert a string or number to a floating point number, if possible.""" | ||
''' in read_module_text("builtins.pyi") | ||
|
||
|
||
@mark.skipif(sys.platform != "win32", reason="windows only") | ||
@mark.needs_all_docstubs | ||
def test_windows_only_docstring(): | ||
assert read_module_text("nt.pyi").startswith('''""" | ||
This module provides access to operating system functionality that is | ||
standardized by the C Standard and the POSIX standard (a thinly | ||
disguised Unix interface). Refer to the library manual and | ||
corresponding Unix manual entries for more information on calls. | ||
"""''') | ||
|
||
|
||
@mark.skipif(sys.platform == "win32", reason="method does not exist on windows") | ||
@mark.needs_all_docstubs | ||
def test_linux_or_mac_only_docstring(): | ||
assert ''' | ||
def tzset() -> None: | ||
""" | ||
tzset() | ||
Initialize, or reinitialize, the local timezone to the value stored in | ||
os.environ['TZ']. The TZ environment variable should be specified in | ||
standard Unix timezone format as documented in the tzset man page | ||
(eg. 'US/Eastern', 'Europe/Amsterdam'). Unknown timezones will silently | ||
fall back to UTC. If the TZ environment variable is not set, the local | ||
timezone is set to the systems best guess of wallclock time. | ||
Changing the TZ environment variable without calling tzset *may* change | ||
the local timezone used by methods such as localtime, but this behaviour | ||
should not be relied on. | ||
""" | ||
''' in read_module_text("time.pyi") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from __future__ import annotations | ||
|
||
from subprocess import run | ||
|
||
|
||
def test_version(): | ||
"""pretty useless test, this is mainly just making sure the python wrapper scripts aren't | ||
busted""" | ||
result = run(["basedpyright", "--version"], check=True, capture_output=True) | ||
assert result.returncode == 0 | ||
assert result.stdout.startswith(b"basedpyright ") | ||
assert b"based on pyright " in result.stdout |