Bug 1285299 - [TEMP] Add test_logging.py to test Mn-h logging; draft
authorAnjana Vakil <anjanavakil@gmail.com>
Wed, 07 Sep 2016 19:02:06 +0200
changeset 411599 41c3d9b0cd8fd17d4d538adf751614d488a66e6b
parent 411598 6af4d9c3737450b6c7af950e0bc5605c35d4293c
child 530769 4f486f7dd077f03658fcb59067f1c9306e7af039
push id28936
push userbmo:anjanavakil@gmail.com
push dateThu, 08 Sep 2016 09:45:30 +0000
bugs1285299
milestone51.0a1
Bug 1285299 - [TEMP] Add test_logging.py to test Mn-h logging; (This is a temporary commit to test the functionality of previous commits in this patch series. It is for review purposes only and should be dropped before landing.) Add a test module `test_logging.py` to the Marionette harness unit tests, for testing the log output of Mn-h on Treeherder using the new pytest_mozlog plugin. MozReview-Commit-ID: 4ZpI378bZQR
testing/marionette/harness/marionette/tests/harness_unit/test_logging.py
new file mode 100644
--- /dev/null
+++ b/testing/marionette/harness/marionette/tests/harness_unit/test_logging.py
@@ -0,0 +1,74 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+import pytest
+
+
+def test_sample_test_pass():
+    assert True
+
+
+def test_sample_test_fail():
+    x = 5
+    assert x == 10
+
+
+def test_sample_test_exception():
+    notathing
+    assert True
+
+
+@pytest.mark.skip(reason="skipping passing test")
+def test_sample_skip_pass():
+    assert True
+
+
+@pytest.mark.skip(reason="skipping failing test")
+def test_sample_skip_fail():
+    assert False
+
+
+@pytest.mark.skip
+def test_sample_unconditional_skip():
+    assert False
+
+
+@pytest.mark.skipif(True, reason="skipping on condition")
+def test_sample_skipif():
+    assert False
+
+
+@pytest.mark.xfail
+def test_sample_expected_fail():
+    x = 5
+    assert x == 10
+
+
+@pytest.mark.xfail
+def test_sample_unexpected_pass():
+    assert True
+
+
+@pytest.fixture()
+def bad_fixture():
+    raise Exception("Faulty pytest fixture")
+    return True
+
+
+def test_setup_error(bad_fixture):
+    assert bad_fixture
+
+
+if __name__ == '__main__':
+    import sys
+    import os
+    log_filename_root = os.path.join(os.path.dirname(__file__), 'logs/test_logging_log')
+    # Uses pytest-mozlog plugin defined in conftest.py for `--log-` options
+    sys.exit(pytest.main(['--verbose', '-s', __file__]))
+    # sys.exit(pytest.main(['-p', 'no:terminalreporter', '--log-tbpl', '-',
+    #                       '--verbose',
+    #                       __file__,
+    #                       '--log-raw', log_filename_root + '.raw',
+    #                       '--log-tbpl', log_filename_root + '.tbpl',
+    #                       '--log-mach', log_filename_root + '.mach',
+    #                       ]))