Benign openbsd Download

www/py-pytest-flask 1.3.0

Legitimate pytest plugin

Flask web framework usageArchive ships a root-level test tree

Evidence

Imports Python's socket module live_server.py · lines 1–24
1import logging
2import multiprocessing
3import os
4import platform
5import signal
6import socket
7import time
8
9import pytest
10
11
12# force 'fork' on macOS
13if platform.system() == "Darwin":
14 multiprocessing = multiprocessing.get_context("fork")
15
16
17class LiveServer: # pragma: no cover
18 """The helper class used to manage a live server. Handles creation and
19 stopping application in a separate process.
20
4 lines
Sets Python thread daemon flag after creation live_server.py · lines 43–53
43:33(self.app, self.host, self.port)
44 )
45 self._process.daemon = True
46 self._process.start()
47
6 lines
Short Python socket connect call live_server.py · lines 58–68
58:14 keep_trying = False
59
60 def _is_ready(self):
61 sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
62 try:
63 sock.connect((self.host, self.port))
64 except socket.error:
65 ret = False
66 else:
67 ret = True
68 finall
Python sends a process signal live_server.py · lines 88–99
4 lines
92 """
93 try:
94 os.kill(self._process.pid, signal.SIGINT)
95 self._process.join(timeout)
96 return True
97 except Exception as ex:
98 logging.error("Failed to join the live server process: %r", ex)
99
References a loopback HTTP URL fixtures.py · lines 14–56
9 lines
23 """Uses to set a ``client`` class attribute to current Flask test client::
24
25 @pytest.mark.usefixtures('client_class')
26 class TestView:
27
28 def login(self, email, password):
29 credentials = {'email': email, 'password': password}
30 return self.client.post(url_for('login'), data=credentials)
31
32 def test_login(self):
33 assert self.login('[email protected]', 'pass').status_code == 200
34
35 """
6 lines
42 """Run application in a separate process.
43
44 When the ``live_server`` fixture is applied, the ``url_for`` function
45 works as expected::
46
47 def test_server_is_up_and_running(live_server):
48 index_url = url_for('index', _external=True)
49 assert index_url == 'http://localhost:5000/'
50
51 res = urllib2.urlopen(index_url)
52 assert res.code == 200
53
54 """
55 # Set or get a port
56 port = app.config.get("LIVESERVER_PORT", Non

Showing the top 5 files — 5 more files (23 regions) not shown.

No evidence locations were recorded for this file. Raw result

Keyboard shortcuts on this page: j for the next sample, k for the previous one, x to go back to the feed, d to download the original bytes, r to re-queue the sample for analysis.