tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_stop.py (1148B)


      1 #!/usr/bin/env python
      2 # This Source Code Form is subject to the terms of the Mozilla Public
      3 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
      4 # You can obtain one at http://mozilla.org/MPL/2.0/.
      5 
      6 import signal
      7 
      8 import mozunit
      9 
     10 
     11 def test_stop_process(runner):
     12    """Stop the process and test properties"""
     13    runner.start()
     14    returncode = runner.stop()
     15 
     16    assert not runner.is_running()
     17    assert returncode not in [None, 0]
     18    assert runner.returncode == returncode
     19    assert runner.process_handler is not None
     20    assert runner.wait(1) == returncode
     21 
     22 
     23 def test_stop_before_start(runner):
     24    """Stop the process before it gets started should not raise an error"""
     25    runner.stop()
     26 
     27 
     28 def test_stop_process_custom_signal(runner):
     29    """Stop the process via a custom signal and test properties"""
     30    runner.start()
     31    returncode = runner.stop(signal.SIGTERM)
     32 
     33    assert not runner.is_running()
     34    assert returncode not in [None, 0]
     35    assert runner.returncode == returncode
     36    assert runner.process_handler is not None
     37    assert runner.wait(1) == returncode
     38 
     39 
     40 if __name__ == "__main__":
     41    mozunit.main()