Commit graph

71 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
Cosine Chen
0e229fcc8c
Always load rc files except --no-rc is passed (#5099) 2023-07-26 22:44:55 +00:00
Noorhteen Raja NJ
479413b5d0
Ruff linter (#5118) 2023-04-19 12:59:32 +00:00
Ivan Ogasawara
2a63f1f875
Improve error message for RAISE_SUBPROC_ERROR=True (#5072)
* Improve error message for RAISE_SUBPROC_ERROR=True

* Fix tests

* Add colors to the short output

* Move the colored code to a function

* Fix output
2023-03-05 07:49:42 +05:30
Noorhteen Raja NJ
3716f3da86
Pr5 xontrib entrypoints (#4827) 2022-06-17 12:39:12 -04:00
Noortheen Raja
f2b7d4ed4f style: sort imports 2022-03-24 19:49:30 +05:30
Noortheen Raja
81b65556a5 chore: update tests 2022-03-24 19:49:30 +05:30
dev2718
7e84e7b003
feat: make stracktraces behave like in python (#4662)
* feat: better stacktraces

* reraise SystemExit to enable proper exit codes and maintain old
behaviour in repl

* dont ignore exceptions when loading rc-files

* update tests with new SyntaxError formatting, new behavior that main
does not throw user exceptions

* pull return out of finally (flake8, B012)

* hide XonshError traces, fix mypy error, enable circumvention of trace suppression
with XONSH_DEBUG in non-interactive use

* fix mypy error

Co-authored-by: Alexander Firbas <alexander.firbas@gmail.com>
2022-02-04 09:16:44 +05:30
Noortheen Raja
78091a22f3 style: isort imports
fix #4584
2022-01-31 11:16:51 -05:00
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
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
50a1c92004
chore: enable flake8 for tests (#4482) 2021-09-26 11:32:24 -04:00
Daniel Shimon
7ce53f1844
Always capture aliases (#4445)
* specs: Make sure sub-specs are always captured regardless of $XONSH_CAPTURE_ALWAYS

* procs: Ensure env is used in functional aliases

* news: Add always-capture-aliases

* tests: procs: Skip known issues

* tests: Restore all builtins in the 'xonsh_builtins' fixture

* tests: vc: Use monkeypatch to mock CommandsCache functions

* tests: main: Don't use the local machine's xonshrc
2021-09-15 15:14:28 -04:00
Noorhteen Raja NJ
d7dbfa9011
Lab/py control file (#4420)
* feat: use python's compile for rc.py

* docs: add news item

* docs: update news item

* test: add tests for py-control files

* fix: rst news item

* docs: update news item

* docs: add sample rc.py
2021-08-19 12:40:22 -04:00
Gordon Ball
e59ac28d7d
Support --rc DIR (#4422)
* args: accept --rc dir to load dir/*.xsh

* test_main: add a test for --rc dir

* args: drop unused --config-path, not read anywhere

* news: add entry for rcdir changes
2021-08-19 12:14:20 -04:00
Gordon Ball
14c2c3ce62
Don't modify XONSHRC and XONSHRC_DIR during startup (#4408)
* xonshrc_context: return loaded instead of context, don't touch env

This function returned the context, but the return value is not used by
the sole call site (and would inconsistently be either the env or ctx
depending on other arguments). Redefine the function to return what was
loaded.

The function will also no longer touch the environment variables
XONSHRC, XONSHRC_DIR or LOADED_RC_FILES.

* XonshSession: add rc_files list, and set in start_services

* LOADED_RC_FILES: drop completely

* xonfig: add RC files

* test_main: update tests for changes to XONSHRC{,_DIR}

* news: add entry for xonshrc changes
2021-08-17 11:01:41 -04: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
Gordon Ball
e02c7d76c4
Test RC loading in different startup configurations (#4279)
* test_main: test lots of startup order combinations

This is based on the startup order described in
https://github.com/xonsh/xonsh/issues/4096#issuecomment-791991841
and adds an (ugly) parameterised test which tries lots of different
CLI combinations, and verifies which RC files (if any) get loaded,
and in what order.

* test_script_startup: skip on windows
2021-05-14 16:12:34 +03:00
Gordon Ball
d48c93bdb5
Add support for rc.d drop-in configuration directories (#4256)
* Add support for rc.d drop-in configuration directories

* main: change how --rc, --no-rc are handled

Explicitly pass --no-rc rather than signalling it as an empty --rc, to
indicate that we should suppress both XONSHRC and XONSHRCDIR in that
case.

* Rename XONSHRCDIR -> XONSHRC_DIR

* xonshrc_context: document setting env for XONSHRC_DIR

* main: --rc foo.xsh should suppress XONSHRC_DIR
2021-05-11 16:42:37 -04:00
Andy Kipp
16884fc605
Update test_main.py (#4223) 2021-04-07 14:37:21 -04:00
Noorhteen Raja NJ
c2d5e60799
Py39 support (#4101)
* fix: handle ast.Index and ast.ExtSlice change while Parsing

related to #4100, #4099, #4068, #4038, #4028, #4005,

* fix: py39 raises when lineno & col not given

TypeError: required field "col_offset" missing from keyword

* fix: tuple inside scbscriptor support for py39

* chore: enable py39 ci checks

they were silently failing before

* test: a backlog test for attributes inside subscriptors

this would require debugging deep into the ply parser methods.

* docs: add news item

* test: skip test_rc_with_modified_path on windows

* Update tests/test_parser.py

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>

* test: mark failing tests for py39 parser

Co-authored-by: Gil Forsyth <gforsyth@users.noreply.github.com>
2021-02-17 12:31:33 -05:00
Leandro Emmanuel Reina Kiperman
e7e6fd90a7
Edit sys.path while loading RC files (squashed) (#3950) 2021-01-04 12:31:05 -05:00
Bob Hyman
dde73ba72c Xonsh failback to /usr/bin/bash in preference to /etc/shells 2020-06-25 19:49:04 -04: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
Gil Forsyth
6e09e3c266
Non-zero exit code when script path not found 2019-09-09 14:39:36 -04:00
Gil Forsyth
c0b7d1166a
Skip broken test on Windows (sorry)
This is a workaround for strange non-deterministic behavior in pytest
2019-07-13 14:56:17 -04:00
Jean-Benoist Leger
30afd0d13a
Properly clean builtins.__xonsh__ before running test in tests/test_main.py 2019-04-19 23:19:25 +02:00
Anthony Scopatz
1c6b1e1ea4 black 2019-02-13 18:49:39 -05:00
Jake Hedman
7d9e2c617c premain --timings test
Add (currently failing) test to make sure the --timings flag does not
crash xonsh on start.
2018-11-27 22:30:29 +01:00
Jake Hedman
cd730aef4f Reset XonshSession in teach main.py test
Unset builtins.__xonsh__ in shell fixture to make sure main.py tests
pass even if the XonshSession has not been touched by previous tests.

Also set $XONSH_CACHE_SCRIPTS in os.environ instead of
builtins.__xonsh__.env since it's not yet created.
2018-11-27 22:30:29 +01:00
Mickaël Schoentgen
ba2fd9bb00 Fix several ResourceWarning: unclosed file in tests 2018-11-09 10:08:03 +01:00
Anthony Scopatz
89a42458d9 tests pass! 2018-09-13 16:49:09 -04:00
Anthony Scopatz
8c3c357c40 all tests run, but don't pass 2018-09-13 15:19:56 -04: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
2086a58993 fixed monkey patched test_main shell 2018-07-14 18:05:54 -05:00
Gil Forsyth
12362d7dd5 Resolve behavior between script call and -i 2017-09-27 19:16:14 -04:00
Gil Forsyth
14df0792de Preserve xonsh interactive flag when running scripts 2017-09-27 19:16:14 -04:00
Gil Forsyth
1f464fb193 Don't load xonshrc is xonsh is running a script
As per discussions with @asmeurer -- if xonsh is being used to launch a script,
e.g.

```
xonsh run_my_cool_deploy.xsh
```

then it should not load the `xonshrc` file since this should be reserved for
interactive functionality and we don't want side effects in the script.

Basically, if you need a xontrib to be loaded for your script, load it in your
script
2017-09-27 19:16:14 -04:00
Gil Forsyth
d33003959e add test for --rc flags 2017-04-21 14:34:47 -04:00
Anthony Scopatz
773069c4f5 Xonsh startup loading refactor 2017-02-13 00:25:38 -05:00
Hugo Wang
335fc71bc7 xonsh script.xsh should not fail over 2017-01-11 21:59:42 +08:00
Hugo Wang
e77695609b raise original error 2016-12-20 12:29:46 +08:00
Hugo Wang
b2078c3f83 updated ut - force it to be interactive 2016-12-18 11:25:39 +08:00
Hugo Wang
76b898ab14 refactoring & updated ut 2016-12-18 11:07:53 +08:00
Hugo Wang
be5dd8e328 failback only for interactive mode 2016-12-18 02:32:08 +08:00
Hugo Wang
d6294e171f ignore screen too 2016-12-17 18:54:28 +08:00
Hugo Wang
6684c802cc failback should ignore xonsh 2016-12-17 18:22:34 +08:00
Hugo Wang
3980da870e make xonsh able to failback to other shells 2016-12-17 18:10:29 +08:00
laerus
daf1928dd0 'fixtures docs' 2016-07-03 12:00:24 +03:00