diff --git a/.gitattributes b/.gitattributes index b043e711aa..9656b8609c 100644 --- a/.gitattributes +++ b/.gitattributes @@ -14,7 +14,7 @@ /zproject/local_settings.py export-ignore /zproject/test_settings.py export-ignore /zerver/fixtures export-ignore -/zerver/tests.py export-ignore +/zerver/tests export-ignore /frontend_tests export-ignore /node_modules export-ignore /humbug export-ignore diff --git a/README.dev.md b/README.dev.md index a13d90d620..9ae15ad1de 100644 --- a/README.dev.md +++ b/README.dev.md @@ -465,7 +465,7 @@ time debugging a test failure, e.g.: ``` ./tools/lint-all # Runs all the linters in parallel -./tools/test-backend zerver.test_bugdown.BugdownTest.test_inline_youtube +./tools/test-backend zerver.tests.test_bugdown.BugdownTest.test_inline_youtube ./tools/test-js-with-casper 10-navigation.js ./tools/test-js-with-node # Runs all node tests but is very fast ``` diff --git a/docs/directory-structure.rst b/docs/directory-structure.rst index a3e475451c..2825f32a13 100644 --- a/docs/directory-structure.rst +++ b/docs/directory-structure.rst @@ -76,7 +76,7 @@ Tests ===== +------------------------+-----------------------------------+ -| ``zerver/test*.py`` | Backend tests | +| ``zerver/tests/`` | Backend tests | +------------------------+-----------------------------------+ | ``frontend_tests/node`` | Node Frontend unit tests | +------------------------+-----------------------------------+ diff --git a/docs/integration-guide.md b/docs/integration-guide.md index a240f3bd0d..a4940ae862 100644 --- a/docs/integration-guide.md +++ b/docs/integration-guide.md @@ -71,14 +71,14 @@ Here's how we recommend doing it: usually just have more complex parsing which can obscure what's common to all webhook integrations. -* Then write a test for your fixture in `zerver/test_hooks.py`, and +* Then write a test for your fixture in `zerver/tests/test_hooks.py`, and you can iterate on the tests and webhooks handler until they work, all without ever needing to post directly from the server you're integrating to your Zulip development machine. To run just the tests from the test class you wrote, you can use e.g. ``` - test-backend zerver.test_hooks.PagerDutyHookTests + test-backend zerver.tests.test_hooks.PagerDutyHookTests ``` See diff --git a/docs/markdown.md b/docs/markdown.md index 9a3a639dad..0e937688a8 100644 --- a/docs/markdown.md +++ b/docs/markdown.md @@ -11,7 +11,7 @@ javascript, based on marked (`static/js/echo.js`), and is used to preview and locally echo messages the moment the sender hits enter, without waiting for round trip from the server. The two implementations are tested for compatibility via -`zerver/test_bugdown.py` and the fixtures under +`zerver/tests/test_bugdown.py` and the fixtures under `zerver/fixtures/bugdown-data.json`. The javascript implementation knows which types of messages it can diff --git a/docs/new-feature-tutorial.rst b/docs/new-feature-tutorial.rst index 7a7333af63..ff3975e653 100644 --- a/docs/new-feature-tutorial.rst +++ b/docs/new-feature-tutorial.rst @@ -62,8 +62,8 @@ process. **Testing:** There are two types of frontend tests: node-based unit tests and blackbox end-to-end tests. The blackbox tests are run in a headless browser -using Casper.js and are located in ``zerver/tests/frontend/tests/``. The unit -tests use Node's ``assert`` module are located in ``zerver/tests/frontend/node/``. +using Casper.js and are located in ``frontend_tests/casper_tests/``. The unit +tests use Node's ``assert`` module are located in ``frontend_tests/node_tests/``. For more information on writing and running tests see the :doc:`testing documentation `. diff --git a/docs/testing.rst b/docs/testing.rst index 3aa121693d..f9ab36c4f4 100644 --- a/docs/testing.rst +++ b/docs/testing.rst @@ -53,8 +53,8 @@ it. On Ubuntu: Backend Django tests -------------------- -These live in ``zerver/tests.py`` and ``zerver/test_*.py``. Run them -with ``tools/test-backend``. +These live in ``zerver/tests/tests.py`` and +``zerver/tests/test_*.py``. Run them with ``tools/test-backend``. Web frontend black-box casperjs tests ------------------------------------- diff --git a/tools/test-backend b/tools/test-backend index 1676cd6b8b..4edc7731a1 100755 --- a/tools/test-backend +++ b/tools/test-backend @@ -30,7 +30,7 @@ if __name__ == "__main__": (options, args) = parser.parse_args() if len(args) == 0: - suites = ["zerver"] + suites = ["zerver.tests"] else: suites = args diff --git a/zerver/decorator.py b/zerver/decorator.py index d741d41b71..f46c64f5a6 100644 --- a/zerver/decorator.py +++ b/zerver/decorator.py @@ -573,13 +573,13 @@ def profiled(func): """ This decorator should obviously be used only in a dev environment. It works best when surrounding a function that you expect to be - called once. One strategy is to write a test case in zerver/tests.py - and wrap the test case with the profiled decorator. + called once. One strategy is to write a backend test and wrap the + test case with the profiled decorator. You can run a single test case like this: - # edit zerver/tests.py and place @profiled above the test case below - ./tools/test-backend zerver.RateLimitTests.test_ratelimit_decrease + # edit zerver/tests/test_external.py and place @profiled above the test case below + ./tools/test-backend zerver.tests.test_external.RateLimitTests.test_ratelimit_decrease Then view the results like this: diff --git a/zerver/test_bugdown.py b/zerver/tests/test_bugdown.py similarity index 99% rename from zerver/test_bugdown.py rename to zerver/tests/test_bugdown.py index f1b93d7fde..7cc9bee173 100644 --- a/zerver/test_bugdown.py +++ b/zerver/tests/test_bugdown.py @@ -138,7 +138,7 @@ class BugdownTest(TestCase): def load_bugdown_tests(self): test_fixtures = {} - data_file = open(os.path.join(os.path.dirname(__file__), 'fixtures/bugdown-data.json'), 'r') + data_file = open(os.path.join(os.path.dirname(__file__), '../fixtures/bugdown-data.json'), 'r') data = ujson.loads('\n'.join(data_file.readlines())) for test in data['regular_tests']: test_fixtures[test['name']] = test diff --git a/zerver/test_decorators.py b/zerver/tests/test_decorators.py similarity index 100% rename from zerver/test_decorators.py rename to zerver/tests/test_decorators.py diff --git a/zerver/test_email_mirror.py b/zerver/tests/test_email_mirror.py similarity index 100% rename from zerver/test_email_mirror.py rename to zerver/tests/test_email_mirror.py diff --git a/zerver/test_events.py b/zerver/tests/test_events.py similarity index 100% rename from zerver/test_events.py rename to zerver/tests/test_events.py diff --git a/zerver/test_external.py b/zerver/tests/test_external.py similarity index 100% rename from zerver/test_external.py rename to zerver/tests/test_external.py diff --git a/zerver/test_hooks.py b/zerver/tests/test_hooks.py similarity index 100% rename from zerver/test_hooks.py rename to zerver/tests/test_hooks.py diff --git a/zerver/test_messages.py b/zerver/tests/test_messages.py similarity index 100% rename from zerver/test_messages.py rename to zerver/tests/test_messages.py diff --git a/zerver/test_signup.py b/zerver/tests/test_signup.py similarity index 100% rename from zerver/test_signup.py rename to zerver/tests/test_signup.py diff --git a/zerver/test_subs.py b/zerver/tests/test_subs.py similarity index 100% rename from zerver/test_subs.py rename to zerver/tests/test_subs.py diff --git a/zerver/test_unread.py b/zerver/tests/test_unread.py similarity index 100% rename from zerver/test_unread.py rename to zerver/tests/test_unread.py diff --git a/zerver/test_urls.py b/zerver/tests/test_urls.py similarity index 100% rename from zerver/test_urls.py rename to zerver/tests/test_urls.py diff --git a/zerver/tests.py b/zerver/tests/tests.py similarity index 100% rename from zerver/tests.py rename to zerver/tests/tests.py