Because of the mechanism for catching exceptions in pubs, the
UnexpectedInput exception raised by FakeInput never reached the catch
statement in the CommandTestCase and raised a FakeSystemExit instead.
This commit monkey-patches the exception handler in the ui at the same
time as the patching of the input functions to ignore UnexptectedInput
at the ui level.
This allows the user to add a reference via an arXiv ID similarly to how a reference can be added
from a DOI or ISBN. If the arXiv ID has a DOI associated with it (according to the arXiv server),
the DOI will be used. If it does not (perhaps the paper is unpublished), then a bibtex entry will
automatically be generated from the reference's metadata.
Note that a potential issue with this addition is that if a paper is added before it is published
(i.e., there is no DOI associated with it), and the paper is later published, the updated
information will have to be manually added.
This involved many changes, some side effects of the change include:
- remove of all `u"abc"` forms, in favor of
`from __future__ import unicode_literals`. Their usage was
inconsistent anyway, leading to problems when mixing with
unicode content.
- improve the tests, to allow printing for usecase even when
crashing. Should make future test easier. This is done with a
rather hacky `StdIO` class in `p3`, but it works.
- for some reason, the skipped test for Python 2 seems to work
now. While the previous point might seem related, it is not clear
that this is actually the case.
Current code version is added to the cache on writting. If the cache
version does not match the code version on read, the cache is ignored
which means it resets.
Added DOI regex function to utils.py which is called in add_cmd.py
upon specifying a new DOI. DOI validation applies directly on
argument parsing by using a custom argparse.Action.
Additionally, reverted FakeSystemExit subclassing Exception, but added
an explicit __init__ so that we can emulate the SystemExit.code
functionality without having to change the superclass.
Unittest just checks that both `pubs` and `pubs --help` raise a
`SystemExit` exception with error code 0. Due to how argparse
handles the `--help` keyword, this is the best way I could think to
provide test coverage without heavily modifying the parser structure
or the unittest infrastructure.
To ensure the `pubs` matches the behavior of `pubs --help`, it now
raises the same `SystemExit(0)` exception via `sys.exit(0)`. And
in order to catch it in the unittest, I had to modify the
`FakeSystemExit` behavior slightly.
Made subparsers not required in the main parser, but if no commands are parsed,
then the parser prints its help. When a command is present, the normal
functionality preserved.
Removed the single unittest that checks for this exact behavior.
For now, the editor_input and edit_file functions do not make sense
outside of the context of an ui. Having them in the content module
was confusing. (See issue fixed by a600855.)
Replace the in-house stubbing by the facilities offered
by pyfakefs for running tests. We don't use `io.open`
anymore, because pyfakefs does not stub it correctly.
We rely on a patched version of pyfakefs, as a few bug
remain in the official repo.
The implementation is designed to be robust to filesystems having integers
or nanosecond stat time.
Added a requirements.txt file for the tests:
`pip install -r tests/requirements.txt` to install the necessary packages
to run the tests.
Fix#13, Fix#14
1. Removed the unicode wrapper around fake_env io
2. Overrided pyfakefs cStringIO with StringIO (Python 2.x)
3. copy_dir will copy file in binary file to the fake filesystem
*unless* they are bib, yaml, txt or md files
4. ui.handle_exception() conserve traceback
Numerous unicode subtelties required diving into pyfakefs and configobj
source code. Unicode on Python 2.x is the worst.
Actually the test not only is expected to fail but it misses a file
which causes an error instead of a failure on python 2. Should be
addressed by #25.
This test is expected to fail. Nose does not handle that yet (treats it as false).
As such, changes have been made to make tests discoverable by unittest.
You may want to uninstall nose and do something like:
alias nosetests="python -m unittest discover"
in your bashrc
Related: #25
Add a theme section in the configuration file to allow users to
set the colors used by different elements of the ui.
Improve the update mechanism so that incremental changes to the
configuration file can be incorporated.
The update is done transparently, and displays a warning message explaining the change.
All the update machinery has been moved to the new update module.
It depends on configobj, is cleaner and simpler than the previous implementation.
It adds comments in the config file, and type verification.
Related: #18