[Pkg-privacy-commits] [onionshare] 164/256: Move choose_port tests into helpers tests, and delete the obsolete onionshare tests. (I really need to write more tests...)

Ulrike Uhlig ulrike at moszumanska.debian.org
Fri May 26 12:53:33 UTC 2017


This is an automated email from the git hooks/post-receive script.

ulrike pushed a commit to branch master
in repository onionshare.

commit adc450c971cf7721f97e054d2b6030765797e091
Author: Micah Lee <micah at micahflee.com>
Date:   Wed Apr 19 09:06:54 2017 -0700

    Move choose_port tests into helpers tests, and delete the obsolete onionshare tests. (I really need to write more tests...)
---
 test/onionshare_helpers_test.py |  9 +++++++++
 test/onionshare_test.py         | 17 -----------------
 2 files changed, 9 insertions(+), 17 deletions(-)

diff --git a/test/onionshare_helpers_test.py b/test/onionshare_helpers_test.py
index 71a5f20..6637a5f 100644
--- a/test/onionshare_helpers_test.py
+++ b/test/onionshare_helpers_test.py
@@ -16,6 +16,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
+import socket
 from onionshare import helpers
 
 
@@ -25,3 +26,11 @@ def test_get_platform_returns_platform_system():
     helpers.platform.system = lambda: 'Sega Saturn'
     assert helpers.get_platform() == 'Sega Saturn'
     helpers.platform.system = p
+
+def test_get_available_port_returns_an_open_port():
+    """get_available_port() should return an open port within the range"""
+    for i in range(100):
+        port = helpers.get_available_port(1024, 2048)
+        assert 1024 <= port <= 2048
+        socket.socket().bind(("127.0.0.1", port))
+
diff --git a/test/onionshare_test.py b/test/onionshare_test.py
index 9a1ebf4..05385bb 100644
--- a/test/onionshare_test.py
+++ b/test/onionshare_test.py
@@ -16,20 +16,3 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
-import socket
-from onionshare import OnionShare
-
-
-def test_choose_port_returns_a_port_number():
-    """choose_port() returns a port number"""
-    app = OnionShare()
-    app.choose_port()
-    assert 1024 <= app.port <= 65535
-
-
-def test_choose_port_returns_an_open_port():
-    """choose_port() returns an open port"""
-    app = OnionShare()
-    # choose a new port
-    app.choose_port()
-    socket.socket().bind(("127.0.0.1", app.port))

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onionshare.git



More information about the Pkg-privacy-commits mailing list