Commit graph

42 commits

Author SHA1 Message Date
pre-commit-ci[bot]
66c0490d37
[pre-commit.ci] pre-commit autoupdate (#5271)
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/psf/black: 23.12.1 → 24.1.1](https://github.com/psf/black/compare/23.12.1...24.1.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-01-30 12:23:50 +01:00
Peter Ye
259fbe540c
fix: do not append empty/comment-only input to history (#4822)
* add test for importing empty .xsh file

* test: empty lines do not get appended to history

prompt-toolkit needs its own test outside of test_base_shell.py because it uses a custom _push() method

* fix: do not append empty/comment-only input to history

Adds a compile_empty_tree argument to Execer.compile()
By default, the argument is `True`, and `compile()` returns a compiled `pass` statement for comment-only input.
When the argument is `False`, `compile()` returns `None` for comment-only input.

The base shell and prompt-toolkit shell use `compile_empty_tree = False` so that they get `None` as the compiled code and don't append the command to the history.

* add news

* fix tests
2022-05-26 17:50:08 +05:30
Noorhteen Raja NJ
7c4e207abd
update test xsh usage (#4581)
* todo

* test: remove usage of DummyEnv and setting .env attribute on xession fixture

one step closer to making too much of tweaking to xession during tests

* test: fix tests vox and gitstatus-prompt

* docs: update test-fixture usage

* fix: import flake8 error

* test: remove direct access to XSH in tests

* test: remove usage of XSH in test files

* todo

* test: use tmp-dir to create stubs

* refactor: use fixture factory to mock out XonshSession

* refactor: remove direct access of XSH from functions

* refactor: remove direct access of XSH from functions

* fix: qa checks

* refactor: rename variables to match their values

* test: update failing tests because it had no PATH set previously

* fix: remove builtins usage from pyghooks.py

* style:

* refactor: update tests to use fixtures

* fix: env varialbe is setup per function

some tests accidentally update the env variables and that is leaking
into next tests

* fix: failing vox tests

* test: set commands_cache per test

* test: fix failing tests

* fix: failing tests on linux

ptk-highlight

* fix: failing tests on Windows

cwd-prompt

* test: copy env as to not affect original object

* fix: lazily evaluate cmds-cache in pyghooks

* test: fix failing tests

* fix: qa errors import

* test: set commands-cache per test

while caching path results

* test: speedup test_thread_local_swap

* fix: failing tests on windows

* refactor: Execer doesn't control session

* refactor: XSH.unload will take care of reversing builtins attrs set

* test: use env.update over monkeypatch

* Revert "test: use env.update over monkeypatch"

This reverts commit 010a5022247a098f1741966b8af1bf758663480e.
2022-01-07 17:33:22 -05:00
Angus Hollands
5091c8368e
Refactor: make session loading explicit (#4540)
* Refactor: Don't modify XSH in Execer

This is not an invariant change - the __del__ method of the execer now does not unload the session. This is probably what we want - the session should be the final arbiter of when it goes out of scope, and we might need an explicit mechanism to handle this.

* Refactor: make import hook Execer explicit

This is ugly for now, but helps raise the global state modifications to the surface

* Style: run black

* Refactor: add `update_cache` to `CommandsCache`

Previously a lot of internal usage of `all_commands` was for the updating side-effect. Now we make that a separate routine.

* Refactor: remove args from XonshSession constructor

* Refactor: move non stateful XonshSession methods to __init__

* Refactor: don't create custom class for namespace

* Refactor: auto-generate set of default builtins

* Refactor: set session attributes to None in constructor

* Refactor: don't test hasattr for known attribute

* Refactor: add methods to restore and disable Python exit

* Refactor: add initial value for XSH.aliases

* Refactor: don't default getattr for known attribute

* Refactor: make _lastflush a closer and move to `load()`

* Fix: catch $path even if empty.

This shouldn't ever actually manifest itself, but whilst we're here!

* Refactor: support existing usage of install_import_hooks

* Style: run black

* Refactor: remove unneeded import

* Docs: add news item

* Fix: news item

* Refactor: remove unused arg

* docs: fix news item

* fix: no duplicate calls

add helpers properties to completion-context

* refactor: importing a module should not affect the session

the user has to have XSH loaded before

* fix: todo item for testing imphooks

Co-authored-by: Noortheen Raja <jnoortheen@gmail.com>
2021-12-21 13:07:53 +05:30
Noorhteen Raja NJ
c2d25ac251
pre-commit hook for pyupgrade (#4583)
* chore: add pyupgrade

* refactor: upgrade code to py3.7+

ran `pre-commit run pyupgrade -a` while excluding changes to ply

* fix: flake errors
2021-12-06 14:42:26 -05:00
Noorhteen Raja NJ
38295a1dd9
Remove globals (#4280)
* refactor: remove usage of global variables in abbrevs.py

* chore: add flake8-mutable to prevent mutable defaults

* fix: abbrevs expand test

* refactor: add xonsh session singleton

* refactor: fix circular errors when using xonshSession as singleton

* refactor: remove black magicked builtin attributes

* style: black format tests as well

* refactor: update tests to use xonsh-session singleton

* refactor: update abbrevs to not use builtins

* test: remove DummyCommandsCache and patch orig class

* fix: failing test_command_completers

* test: use monkeypatch to update xession fixture

* fix: failing test_pipelines

* fix: failing test_main

* chore: run test suit as single invocation

* test: fix tests/test_xonsh.xsh

* refactor: remove builtins from docs/conf.py

* fix: mypy error in jobs

* fix: test error from test_main

* test: close xession error in test_command_completers

* chore: use pytest-cov for reporting coverage

this will include subprocess calls, and will increase coverage

* style:
2021-05-20 13:14:26 +03:00
Anthony Scopatz
f048b295d6 black updates to tests and docs 2020-08-26 10:10:59 -05:00
Bob Hyman
26475146e2
Flake8 1 (#3550)
* flake8 fixes -- tests only

* fix ci failure

* integrate fix from is_3551 so tests will pass.

* Update tests/test_builtins.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2020-05-05 06:42:28 -04:00
Jamie Bliss
5087ca0378 Add test 2020-02-11 13:37:20 -05:00
Anthony Scopatz
e84bb926ea try to fix tests 2018-11-19 21:56:58 -05:00
Anthony Scopatz
b32823d236 replace yield fixtures 2018-11-19 20:22:18 -05:00
Anthony Scopatz
4c91df2abc many test fixes 2018-09-13 14:03:35 -04:00
Anthony Scopatz
634a8ec9f2 black tests 2018-08-30 09:18:49 -05:00
Anthony Scopatz
2ed0445a74 first pass at import event hooks 2017-02-19 13:22:01 -05:00
Morten Enemark Lund
8877188cb5 Explicitly instantiate Excer() in test_imphooks.py.
Using the Excer fixture from conftest.py does not instantiate builtins. And calling load_builtins won't work since it is monkeypatched from the fixture.
2017-02-14 21:14:18 +01:00
Anthony Scopatz
214990ed9f cool job 2016-09-08 21:11:51 -04:00
Anthony Scopatz
78a87d0304 some emergency fixup 2016-08-28 09:57:31 -04:00
laerus
bbc965346b cleanup/tests 2016-08-27 13:51:45 +03:00
Matthias Bussonnier
3c7753f4be Fix tests, document, and make install_hook() install only once. 2016-08-10 18:20:54 -07:00
laerus
31c5760182 'typoz' 2016-07-03 12:26:52 +03:00
laerus
0e7c8dc730 'test_imphooks fixture fix' 2016-07-03 12:02:02 +03:00
laerus
daf1928dd0 'fixtures docs' 2016-07-03 12:00:24 +03:00
laerus
a05ca9b6af 'test_imphooks' 2016-07-01 13:52:44 +03:00
Anthony Scopatz
3276d06f01 removed ENV 2016-06-28 20:22:11 -04:00
Konstantinos Tsakiltzidis
b329fffd39 setup_module on test_imphooks 2016-06-23 03:41:36 +03:00
Konstantinos Tsakiltzidis
4b5119fc75 Merge branch 'master' into pytest_port 2016-06-23 03:02:39 +03:00
Gil Forsyth
af70c5d493 denose test imphooks 2016-06-22 17:48:35 -04:00
Gil Forsyth
2c26fcaa64 update setup and teardown calls. only 1 test failing 2016-06-22 11:41:06 -04:00
Gil Forsyth
30831ce840 fix test_imphooks setup 2016-06-22 09:59:18 -04:00
Anthony Scopatz
e88abafc92 pathext windows test fixes 2016-06-21 11:43:08 -04:00
adam j hartz
8e665439c0 update tests 2016-06-10 15:02:39 -04:00
Gil Forsyth
99ea707ae7 fix broken imports in certain tests
these were introduced in a few places but there is no __init__.py file
in the tests directory so the import breaks (at least on my machine)
2016-05-19 15:17:42 -04:00
adam j hartz
07176d664d update tests to have __xonsh_shell__ 2015-12-05 15:32:38 -05:00
Kurtis Rader
e88c863d10 Add a uniform character encoding to all files.
I wouldn't normally do something like this but issue #487 brought to
my attention the fact that too many of the python modules don't have
an encoding comment and of those that do there is a lot of pointless
inconsistency in the style of the comment.
2015-11-16 14:10:40 -08:00
Anthony Scopatz
c964927f10 please work 2015-04-02 20:23:26 -05:00
Anthony Scopatz
a60779966e morro 2015-04-02 20:17:30 -05:00
Anthony Scopatz
ecf201bbf9 more updates 2015-04-02 19:42:38 -05:00
Anthony Scopatz
cf0c023c8e some landscape fixes 2015-04-02 19:11:50 -05:00
Anthony Scopatz
78cc184a15 test subpackage 2015-03-29 22:53:33 -05:00
Anthony Scopatz
08609ca0ca added relative import test 2015-03-29 18:29:56 -05:00
Anthony Scopatz
51bc86ab49 more robust loading / unloading 2015-03-29 18:25:11 -05:00
Anthony Scopatz
8fd9e05b9b first light on import hooks 2015-03-29 17:49:44 -05:00