Commit Graph

210 Commits

Author SHA1 Message Date
Florian Bruhin
a17b8bec90 Don't treat "Hello." as URL with auto-search=naive 2016-08-23 09:02:39 +02:00
Florian Bruhin
f45c4d73f4 Split test_is_url into three separate tests 2016-08-23 08:07:45 +02:00
Florian Bruhin
df3733af54 tests: Use pytest.fixture instead of yield_fixture
See #1877
2016-08-22 07:40:24 +02:00
Florian Bruhin
bd53d4a410 tests: Clean up test_utils 2016-08-20 22:39:53 +02:00
Florian Bruhin
794bdf54a3 tests: Clean up test_log 2016-08-20 21:57:52 +02:00
Florian Bruhin
5367434a13 Add a unit test for :debug-log-filter 2016-08-19 15:20:08 +02:00
Florian Bruhin
0557fea79e Use QApplication.sendEvent instead of postEvent
From the QApplication.postEvent docs:
http://doc.qt.io/qt-5/qcoreapplication.html#postEvent

  The event must be allocated on the heap since the post event queue
  will take ownership of the event and delete it once it has been
  posted. It is not safe to access the event after it has been posted.

We can't reliably guarantee that from Python, so we need to use
sendEvent instead.
2016-08-18 21:36:43 +02:00
Florian Bruhin
4345d60ff1 Revert "javascript.assemble: Support document module"
This reverts commit afc7faabda.

This isn't actually needed as we can't use document.getElementById()
directly without serializing anyways.
2016-08-18 15:58:46 +02:00
Florian Bruhin
afc7faabda javascript.assemble: Support document module 2016-08-18 14:07:21 +02:00
Florian Bruhin
30029a8259 utils.javascript: Handle bools in _convert_js_arg 2016-08-18 12:40:21 +02:00
Peter Rice
67609af21b resolve linter warnings 2016-08-15 22:53:28 -04:00
Peter Rice
d4c16aa3c7 add a test for incdec with a count 2016-08-15 22:53:28 -04:00
Florian Bruhin
29b778b6d6 Use javascript.assemble for all functions 2016-08-10 17:27:34 +02:00
Florian Bruhin
b488d7f9fd Make QtWebKit optional in utils.version 2016-08-10 15:05:15 +02:00
Florian Bruhin
c8a92a0851 Fix test_assemble 2016-08-09 13:23:46 +02:00
Florian Bruhin
627f743c26 Handle float in _convert_js_arg
This fixes 'gg' with QtWebEngine.
2016-08-08 08:04:55 +02:00
Florian Bruhin
0169f3a24f Add _qutebrowser_ prefix for custom JS functions
With QtWebKit or QtWebEngine with Qt < 5.7, the functions end up in the
page's namespace. We can't easily avoid this, but at least we can name
them in a way which reduces conflicts.
2016-08-05 10:31:07 +02:00
Florian Bruhin
74b9b0ba90 Remove unneeded lambda 2016-08-04 18:15:29 +02:00
Florian Bruhin
a8ef956726 Add quotes for strings in javascript.assemble 2016-08-04 17:58:40 +02:00
Florian Bruhin
08b70f0f4c Add qutebrowser.utils.javascript
webelem.javascript_escape got renamed to javascript.string_escape, and a
new javascript.assemble got added to make it easier to call a function
inside a .js file.
2016-08-04 17:53:13 +02:00
Daniel Schadt
1400a27508 more tests for OpenFileDownloadTarget 2016-08-03 18:14:45 +02:00
Daniel Schadt
716ce701f5 utils: move elide_filename to own function
Also increase the elide limit in TempDownloadManager to 50, since that's
probably still enough for all systems.
2016-08-03 17:59:32 +02:00
Florian Bruhin
9851a13981 Add utils.random_port() 2016-08-03 13:08:55 +02:00
Florian Bruhin
4a5b5c496f Fix using a relative path with --basedir 2016-08-02 14:08:28 +02:00
Florian Bruhin
4bf94f3c24 Use order='strict' with qtbot.waitSignals
See #1702
2016-07-29 09:12:06 +02:00
Florian Bruhin
a7e9b4e5d7 Get rid of extend=True for qt_log_ignore
This is now the default, see #1702
2016-07-29 09:12:06 +02:00
Florian Bruhin
ccbd47a0cd Merge branch 'savefile_open-flush' of https://github.com/flv0/qutebrowser into flv0-savefile_open-flush 2016-07-27 10:11:33 +02:00
Florian Bruhin
f4f6a3dac1 Merge branch 'open-download' of https://github.com/Kingdread/qutebrowser into Kingdread-open-download 2016-07-26 10:32:34 +02:00
Florian Bruhin
64f208486e Add log.ignore_py_warnings() 2016-07-23 13:04:45 +02:00
Florian Bruhin
76eab7617b Remove @pyqtSlot for functions and non-QObjects
Fixes #1669
2016-07-23 11:42:50 +02:00
Ryan Roden-Corrent
9c9b367887 Completely prevent tests from creating cachedir.
Attempting to fix the test on windows caused it to create the cachedir
again. The call to init(None) was unnecessary.
2016-07-15 13:46:50 -04:00
Ryan Roden-Corrent
cee5d6b97f Use fake_args in test_standarddir. 2016-07-15 13:46:50 -04:00
Ryan Roden-Corrent
34583d1565 Fix standarddir test on Windows.
Was broken by 48a2cad while trying to prevent creation of qute_test in
non-temp locations.
2016-07-15 13:46:50 -04:00
Ryan Roden-Corrent
1f71520bb2 Prevent tests from creating cachedir tag.
Running test_standarddir would pollute the user's home with
`~/.cache/qute_test`.

The `no_cachedir_tag` fixture was supposed to prevent this, but was not
working because [usefixtures does not work on fixtures]
(https://github.com/pytest-dev/pytest/issues/1014).

This fixes the fixture to actually prevent cachedir creation, but
applies it to tests individually (or by class) rather than with autouse
because the cachedir tests cannot pass if it is working.
2016-07-15 13:46:50 -04:00
Ryan Roden-Corrent
daaa5ff5c5 Don't create real config/data dirs from tests.
Running the tests would create ~/.config/qute_test and
~/.local/share/qute_test on the user's machine. The test_standardir
module needed a bit more mocking to prevent it from cluttering the
user's machine.

Two tests that created the data dir were fixed by passing basedir in
args, and one test that created the config dir was fixed by patching
os.makedirs to a noop.
2016-07-15 13:46:50 -04:00
Daniel Schadt
029ffe3fc7 tests: add tests for usertypes.DownloadTarget 2016-07-13 14:17:41 +02:00
Jan Verbeek
bbc46d28ff Use lists instead of tuples for comparing
Per one of the diff comments on #1597:
> I used to use a tuple for constant things, but nowadays I'd actually
> prefer a list as a tuple is something more heterogeneous (i.e. it
> makes sense to have a `(x, y)` point as a tuple, but a list of points
> would be a list).
> At some point I should probably change it to a list everywhere 😉
2016-07-12 22:05:32 +02:00
Florian Bruhin
64dc099d51 pylint: Enable docstyle extension 2016-07-11 13:47:18 +02:00
Florian Bruhin
2136d00aa2 tests: Add a fake_args fixture 2016-07-10 17:04:25 +02:00
Florian Bruhin
06a6daee34 Add stubs for QtWebEngine 2016-07-08 12:53:48 +02:00
Florian Bruhin
29ee605c79 Fix version output test on Windows
On Windows we get something like C:\IMPORTPATH instead of /IMPORTPATH
2016-07-07 18:32:13 +02:00
Florian Bruhin
674b316db3 Simplify test_version_output 2016-07-07 09:14:36 +02:00
Florian Bruhin
ebf9bc4e0a Improve version output 2016-07-06 23:47:59 +02:00
Florian Bruhin
70117265d6 Fix some a/an misspellings
Thanks to https://github.com/jwilk/anorack
2016-07-05 08:34:03 +02:00
Patric Schmitz
217b912f3c revert custom exception throwing in savefile_open
instead adapt test_failing_flush to catch correct exception (ValueError).
2016-06-28 15:03:23 +02:00
Patric Schmitz
a33978ee89 fix error handling in savefile_open and tests 2016-06-28 12:59:00 +02:00
Florian Bruhin
86632804a9 behaviour -> behavior for consistency 2016-06-09 17:30:14 +02:00
Florian Bruhin
ab8a2f7147 Fix lint 2016-06-09 17:12:23 +02:00
Florian Bruhin
2d54c927e3 Fix urlutils tests on Qt 5.6.1
For some reason the behaviour of QHostAddress("31c3").isValid() changed
with Qt 5.6.1: https://bugreports.qt.io/browse/QTBUG-53983

This causes the test to fail because Qt thinks this is a valid IP, so we
think it's a valid URL.
2016-06-09 15:16:49 +02:00
Florian Bruhin
e8123bb68a Fix pdfjs version parsing for never versions 2016-06-07 07:42:34 +02:00
Florian Bruhin
abfd789f9e Fix zooming with a too big count
Fixes #1118
Supersedes #1140
2016-06-06 13:25:01 +02:00
Florian Bruhin
8d5fdf2833 Remove wrap mode for NeighborList 2016-06-06 13:10:14 +02:00
Daniel Schadt
d4a295b22e tests: update test_log with json_logging namespace 2016-05-30 16:00:10 +02:00
Florian Bruhin
86be7ad82c Move file_url from utils.jinja to utils.urlutils 2016-05-29 22:44:40 +02:00
Tarcisio Fedrizzi
ec2935fab0 Fixes flake8 error 2016-05-28 17:38:31 +02:00
Tarcisio Fedrizzi
a3e6761db6 Fixes pylint error 2016-05-26 18:01:01 +02:00
Tarcisio Fedrizzi
a9e96df5df Adds unit test when force_search is True 2016-05-26 18:01:01 +02:00
Tarcisio Fedrizzi
462f9d7e4c Refators discussed in the review
- refactors what discussed in the review
- adds unit tests for schemas without host and path
2016-05-26 18:01:01 +02:00
Ryan Roden-Corrent
b1440a1804 Implement utils.is_special_key.
The check `key.startswith('<') and key.endswith('>') is repeated many
times in code to check for a special key. Replace all these with a call
to the same function.
2016-05-19 20:48:48 -04:00
Florian Bruhin
c0d044447d Add tests for qutebrowser.utils.typing 2016-05-18 06:55:17 +02:00
Florian Bruhin
3a33bc42a6 Add initial support for the typing module 2016-05-18 06:55:17 +02:00
Florian Bruhin
c64e5c9bd5 Get rid of the colorlog dependency
colorlog was problematic for various reasons:

- Not commonly packaged for Linux distributions
- Calling colorama.init() automatically on import
- Not supporting {foo} log formatting
- Not supporting an easy way to turn colors off

Instead we now do the log coloring by hand, which is simpler and means
everyone will have colored logs.
2016-05-13 21:19:33 +02:00
Florian Bruhin
a23aa1cc47 Fix broken supports_selection() test 2016-05-08 22:39:39 +02:00
Florian Bruhin
b9b6f357da Add utils.supports_selection() 2016-05-08 22:06:59 +02:00
Florian Bruhin
43d898aa63 Fix log tests 2016-04-30 17:45:45 +02:00
Florian Bruhin
2a343cb3a1 Various code style improvements 2016-04-27 20:25:27 +02:00
Florian Bruhin
387e35d3e5 Fix lint 2016-03-26 00:24:54 +01:00
Florian Bruhin
9edc5a665e Handle jinja's UndefinedError in jinja.render
We can get UndefinedError when a new function got added to the jinja
env (and gets called from a template) and the user did update the
on-disk templates but not restart qutebrowser yet.

In this case, let's show a special error page to the user and tell them
to do :report in the unlikely case it's actually a bug.

Fixes #1362.
See #1360.
2016-03-26 00:00:06 +01:00
Florian Bruhin
86b12a302e Add a jinja.render helper
This simplifies some code and will make #1362 possible.
2016-03-25 14:29:30 +01:00
Clayton Craft
ff4e17190f Allow searching system-wide data path on Linux for userscripts 2016-03-24 13:22:00 -07:00
Tarcisio Fedrizzi
89ac5cba62 Adds test to reach 100% coverage on urlutils 2016-02-28 23:43:38 +01:00
Florian Bruhin
5311576c34 Check pep257 via flake8.
We'll still keep the pydocstyle environment though until flake8-pep257 adds
support for that:

https://github.com/Robpol86/flake8-pep257/issues/6
2016-02-10 19:18:47 +01:00
Florian Bruhin
5ae677376b Rerun TestPyQIODevice.test_qprocess if needed.
This adds a new pytest-rerunfailures dependency. For some reason, that test
sometimes fails with an empty string read, and I can't tell why.
2016-02-08 06:54:47 +01:00
Daniel Schadt
d02ec62e33 tests: fix tests for test_version
Broken since we changed pdfjs.PDFJSNotFound to have a parameter, which
was not given here.
2016-02-05 15:16:23 +01:00
Florian Bruhin
0b491f6caf Use json.dumps for logged fake clipboard.
For some reason, when comparing the repr in the two processes, we get different
results on OS X and Windows:

- expected: "fünf"
- "f\xfcnf" coming back from the subprocess on OS X
- "fnf" on Windows

Instead we're comparing the json dump now, which should be more predictable.
2016-02-03 20:54:35 +01:00
Florian Bruhin
79f83a033d Add a fake clipboard for tests
There are a lot of problems and flakiness with using a real clipboard.

Instead we now have a :debug-set-fake-clipboard command to set a text, and use
logging when getting the contents.

Fixes #1285.
2016-02-03 20:27:11 +01:00
Florian Bruhin
312daca2b0 fuzzy_url: Raise InvalidUrlError on empty URLs.
Before we raised QtValueError (via qtutils.ensure_valid), but maybe there are
more callers out there which call fuzzy_url with an empty input - and it makes
more sense to raise InvalidUrlError which gets displayed to the user than
raising QtValueError which is more like an assertion.
2016-02-02 06:38:48 +01:00
Daniel Schadt
449a54c7d0 pdfjs: add file path to version information
Shows "bundled" if the bundled version is used.
2016-02-01 17:28:18 +01:00
Florian Bruhin
4d9ea06768 tests: Make test IDs predictable.
This means we could use xdist in the future.
2016-01-25 22:15:31 +01:00
Florian Bruhin
7dca8d7329 Fix lint. 2016-01-24 17:30:59 +01:00
Florian Bruhin
86f03c7d81 Merge branch 'master' of https://github.com/mikeri/qutebrowser into mikeri-master 2016-01-24 17:01:35 +01:00
Florian Bruhin
58fb2826ee flake8: Add flake8-putty plugin.
Apply a bit of putty to flake8.
https://pypi.python.org/pypi/flake8-putty/
2016-01-22 17:33:58 +01:00
Florian Bruhin
526441bcae Fix new flake8 lint.
For some reason these issues weren't shown with pytest-pep8/flakes.
2016-01-22 17:33:58 +01:00
Michael Ilsaas
4ad2d63c8a Shortened urlincdec tests to one and some styling 2016-01-21 18:37:46 +01:00
Michael Ilsaas
1ecccc1133 Fix: decrement url test was set to increment. 2016-01-21 17:15:48 +01:00
Michael Ilsaas
c33e9555a1 Tester for url increment/decrement with zeroes 2016-01-20 19:38:03 +01:00
Florian Bruhin
eb276df876 Handle empty term in urlutils._get_search_url.
Fixes #1239.
2016-01-19 07:03:43 +01:00
Tarcisio Fedrizzi
f813bc2415 Adds unit test to check that paths ending with newlines are handled
correctly
2016-01-12 11:27:11 +01:00
Florian Bruhin
1fb34331e5 tests: Default to raising=True for qtbot.
- qtbot.waitSignal with raising=True is the default this way, so we remove the
  raising=True.
- qtbot.waitSignal with raising=False stay untouched
- Some qtbot.waitSignal without raising had one added (because we don't want it
  to raise)
- Some qtbot.waitSignal without raising actually should've raised, which they
  do now.
2016-01-08 09:49:06 +01:00
Florian Bruhin
88d28e690e Add pdf.js version to qute:version. 2016-01-05 18:47:50 +01:00
Florian Bruhin
a5f2ac5f03 Adjust copyright years. 2016-01-04 07:12:39 +01:00
Florian Bruhin
9f64dfb3b6 Skip all tests using py_proc when frozen. 2015-12-21 09:46:30 +01:00
Florian Bruhin
6b89eb43a2 Allow any non-space char in search engine names.
Closes #1189.
2015-12-20 17:22:54 +01:00
Florian Bruhin
e6284ed5d4 tests: Improve some ugly test IDs. 2015-12-16 22:21:29 +01:00
Florian Bruhin
eff0e4c7cc pylint: Enable useless-suppression globally.
We deactivate it locally where needed, i.e. where we are sure it's some
platform-specific thing.
2015-12-01 23:01:09 +01:00
Florian Bruhin
5817b47f75 Revert "Use fully qualified imports in tests."
Seems like this also breaks frozen tests...
This reverts commit c7fdcc92b8.
2015-12-01 22:45:59 +01:00
Florian Bruhin
109984c96e pylint: Check attr-defined-outside-init for tests. 2015-12-01 22:41:16 +01:00
Florian Bruhin
803398c49b Use some more fixtures for older tests. 2015-12-01 22:40:58 +01:00
Florian Bruhin
c7fdcc92b8 Use fully qualified imports in tests.
This is cleaner even if pylint can't handle it.
2015-12-01 22:03:59 +01:00
Florian Bruhin
150a83d8f4 pylint: Remove unneeded supressions. 2015-12-01 22:03:58 +01:00