Commit graph

73 commits

Author SHA1 Message Date
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
Noortheen Raja
e66c08168b test: refactor vox tests
vox create is costly. reuse it between tests
2021-12-23 06:32:47 +05:30
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
5a985427e7
feat: add sub-command to print current completions (#4586)
* feat: `completer complete` command is added to test current completions

* fix: tests
2021-12-12 08:47:47 +05:30
Noorhteen Raja NJ
a3c1b2429e
argparserAlias - vox (#4437)
* feat: use argparser-alias for vox

* feat: vox.create --interpreter completions

* refactor: use func based completer

* fix: implement interpreter completion

* docs:

* refactor: update import path of cli_utils

* style: convert to f-strings

* fix: failing tests

* fix: failing tests

completer from base_completer appears
2021-10-13 10:02:06 -04:00
Noorhteen Raja NJ
33a5689db2
feat: improve pip completer (#4476)
* feat: improve pip completer

* refactor: optimize imports

* fix: update tests for other completers

* fix: failing tests

* test: fix failing tests

* refactor: make error message clear

exception like KeyError will be more clear now

* qs import

* fix: failing tests on windows

* fix: failing tests on windows

* fix: failing tests on windows

* refactor: optimize imports
2021-09-26 11:33:09 -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
e25ab34e32
Add test for readline shell (#4447)
* fix: ReadlineShell pass stdin/out to Cmd's constructor

* test: add test for readline shell

* chore: increase required coverage

* test:

* fix: failing ci pipeline

* fix: failing ci test
2021-09-02 22:15:20 +03:00
Noorhteen Raja NJ
c4b54e06a1
ArgparserAlias - xonfig2 (#4436)
* feat: use ArgparserAlias for xonfig

* test: update test for xonfig completions

* refactor: update docs

* refactor: use function based completer

* fix: remove old import

* docs:

* fix: merge issues

* test: move xsh_with_aliases to root conftest.py

* docs:

* feat: set subparser's prog from func-name
2021-08-28 14:09:59 +03:00
Noorhteen Raja NJ
54f5ae7bb2
Argparser/color+completion (#4391)
* feat: add colored help formatter and alias builder

closes #4284

* feat: add auto-completion support to argparser

* test: update test for completer

* fix: getting doc from params that have annotation

* refactor: use filter-function for checking alias completions

* doc: add discussion abount check for alias having parser

see discussion on
https://github.com/xonsh/xonsh/pull/4267

* type fix

* refactor: use function based completer

* test: fix failing argparser test

* docs: update news item

* update completion for argparser sub-commands to append_space

from comment on
https://github.com/xonsh/xonsh/pull/4267#discussion_r676044508

* docs: update docstring typo

* refactor: move inspect import to top

* feat: support option strings before positionals

and add env setting for showing completions for options by default

* test: update tests after adding new $ALIAS_COMPLETIONS_OPTIONS_BY_DEFAULT

* add suggested completion_context_parse fixture

* docs: add suggested doc for dispatch function

* refactor: use try/except for import of typing.annotated

* refactor: move complete_argparser_aliases to completers/aliases.py

* refactor: move argparser completer to its own module

* style:

* refactor: rename completer to not clash with argparse

* fix: expand option's descriptions

* fix: add completer/argparser to amalgam
2021-08-26 01:32:13 +03:00
Noorhteen Raja NJ
8831aca57f
test: speedup test suit by reusing costly vars (#4384)
* test: speedup test suit by reusing costly vars

* chore: revert changes to xonsh_execer fixture

* revert changes to test_parser
2021-08-10 10:17:20 +03:00
Noorhteen Raja NJ
112440ef63
feat: support var-args signature for aliases (#4379)
* feat: support var-args signature for aliases

* test: add test for callable alias
2021-07-25 13:15:05 +03:00
Noorhteen Raja NJ
3ce8c9b337
add py310 (#4270)
* chore: adding py310 to ci

though this will require code/parser changes, this is to prepare for
upcoming adoption

* fix: set python version as string

* fix: reference to master -> main

* fix: coverage is not reported in master

- disable amalgamation
	1. during coverage report tests
	2. qa tools like mypy may follow imports
- use python 3.9 for coverage and qa report. since it will have more
coverage and better typing support

* chore: use py3.10 with setup-py action

* chore: add news-item check job

* fix: py3.10 error while starting

the match statement is not supported.
while the syntax support is only upto py3.8

* fix: news-item checker

* chore: enable fail report for py310 tests

* test: add test for ptk_shell
2021-06-07 13:40:40 -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
Daniel Shimon
f960d4576f
Improve jedi completer (#4264)
* xontrib: jedi: Don't complete partial paths in commands

E.g. when completing "/bin/a" we don't want jedi to complete "/bin/abs"

* xontrib: jedi: Allow case-insensitive completions

* news: Add improve-jedi-completer
2021-05-11 13:10:58 +03:00
David Strobach
c3a354781b Finalize f-string handler transition
- Moves the f-string handler into a separate FStringAdaptor class.
- Removes helper dictionary mapping int ID to f-string field.
  The f-string fields are now rather patched early directly into the
  AST as an argument to eval_fstring_field. This solves the problems
  with f-string fields lifespan management.
2020-08-17 13:41:11 +02:00
David Strobach
12c8990e53 Fix f-string tests 2020-08-17 04:57:39 +02:00
Bob Hyman
a6bb5e2d56 Run (pure) flake8 in CI; deprecate config for pytest-flake8 2020-05-06 22:49:11 -04:00
Anthony Scopatz
bdf5c730b7 single blank line 2019-10-07 17:07:42 -04:00
Morten Enemark Lund
ea21723dd8 Remove reference to win_unicode_console in tets 2019-10-07 22:23:06 +02: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
Mickaël Schoentgen
ba2fd9bb00 Fix several ResourceWarning: unclosed file in tests 2018-11-09 10:08:03 +01:00
Anthony Scopatz
2d41c591a5 try more attachments and fix further deps warnings 2018-10-11 12:16:31 -04:00
Anthony Scopatz
579ccd07d9 deprecation warning fixes 2018-10-11 12:04:48 -04:00
Anthony Scopatz
147ee78cdb test fixes 2018-10-11 11:22:57 -04:00
Anthony Scopatz
2736a4d187 flake fixes 2018-10-01 18:10:18 -04:00
Anthony Scopatz
61c27ec365 many fixes 2018-10-01 15:48:47 -04:00
Anthony Scopatz
7423238f94 more fixes 2018-10-01 15:31:37 -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
laerus
4a2ff3aa58 conftest xonsh_builtins teardown 2017-02-27 21:44:58 +02:00
Morten Enemark Lund
e78b0448a7 Don't import xonsh.built_ins 2017-02-14 21:29:44 +01:00
Morten Enemark Lund
4f09829fd6 Fix monkeypath load_builins 2017-02-14 21:02:04 +01:00
Anthony Scopatz
3d20fc04de no history 2017-02-13 01:04:56 -05:00
Anthony Scopatz
419984beca new ctx 2017-02-13 00:50:31 -05:00
Anthony Scopatz
773069c4f5 Xonsh startup loading refactor 2017-02-13 00:25:38 -05:00
Jamie Bliss
1a5d832ffe Use the species nomenclature throughout. 2017-01-12 13:29:15 -05:00
Jamie Bliss
972ae6e689 Merge remote-tracking branch 'upstream/master' into event-transform_command 2017-01-12 13:22:23 -05:00
Anthony Scopatz
fa3730cf44 rewrite of xonsh contexts to be based off of macros. 2017-01-10 01:58:21 -05:00
Jamie Bliss
a106e33faf Use the right subclass 2017-01-09 01:52:48 -05:00
Jamie Bliss
793101c387 Move events reset to pytest fixture 2017-01-08 20:31:39 -05:00
Jamie Bliss
66e92d3641 Reset event state after tests. 2017-01-07 15:30:50 -05:00
laerus
b7a1ed4721 added git/hg repos for testing 2016-11-14 21:09:25 +02:00
Gil Forsyth
29af833ad8 fix remaining pep8 violations 2016-10-07 10:57:31 -04:00
Anthony Scopatz
afccd10b6a minor cleanup 2016-09-25 16:40:40 -04:00
Anthony Scopatz
861aedfc4d some minor cleanup 2016-09-24 16:13:14 -04:00
Anthony Scopatz
bde2f985e6 try clearing tasks 2016-09-24 16:09:01 -04:00
Anthony Scopatz
51866ee92e try different singleton 2016-09-24 16:05:48 -04:00
Anthony Scopatz
2ebd81e2b0 some test fixes 2016-09-24 15:28:12 -04:00