We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
test_pyx problem
I have a unit test that uses scapy library like this:
```
$ cat ut.py 
from scapy.all import *

def test_foo():
    pass
```
The problem is that testing framework (pytest) detects internal scapy function test_pyx as a test:
```
ut.py::test_foo PASSED
ut.py::test_pyx <- venv/src/scapy/scapy/consts.py PASSED
```
This is because test_pyx function from scapy/consts.py is unnecessarily imported from scapy.all
and pytest treats all test_* functions as tests.

Scapy from current master branch.



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `scapy/consts.py`
Content:
```
1 ## This file is part of Scapy
2 ## See http://www.secdev.org/projects/scapy for more informations
3 ## Copyright (C) Philippe Biondi <phil@secdev.org>
4 ## This program is published under a GPLv2 license
5 
6 import os, inspect
7 from sys import platform, maxsize
8 import platform as platform_lib
9 from scapy.error import *
10 
11 import subprocess
12 
13 try:
14     from matplotlib import get_backend as matplotlib_get_backend
15     import matplotlib.pyplot as plt
16     MATPLOTLIB = 1
17     if "inline" in matplotlib_get_backend():
18         MATPLOTLIB_INLINED = 1
19     else:
20         MATPLOTLIB_INLINED = 0
21     MATPLOTLIB_DEFAULT_PLOT_KARGS = {"marker": "+"}
22 # RuntimeError to catch gtk "Cannot open display" error
23 except (ImportError, RuntimeError):
24     plt = None
25     MATPLOTLIB = 0
26     MATPLOTLIB_INLINED = 0
27     MATPLOTLIB_DEFAULT_PLOT_KARGS = dict()
28     log_loading.info("Can't import matplotlib. Won't be able to plot.")
29 
30 def test_pyx():
31     """Returns if PyX is correctly installed or not"""
32     try:
33         with open(os.devnull, 'wb') as devnull:
34             r = subprocess.check_call(["pdflatex", "--version"], stdout=devnull, stderr=subprocess.STDOUT)
35     except:
36         return False
37     else:
38         return r == 0
39 
40 try:
41     import pyx
42     if test_pyx():
43         PYX = 1
44     else:
45         log_loading.warning("PyX dependencies are not installed ! Please install TexLive or MikTeX.")
46         PYX = 0
47 except ImportError:
48     log_loading.info("Can't import PyX. Won't be able to use psdump() or pdfdump().")
49     PYX = 0
50 
51 
52 LINUX = platform.startswith("linux")
53 OPENBSD = platform.startswith("openbsd")
54 FREEBSD = "freebsd" in platform
55 NETBSD = platform.startswith("netbsd")
56 DARWIN = platform.startswith("darwin")
57 SOLARIS = platform.startswith("sunos")
58 WINDOWS = platform.startswith("win32")
59 BSD = DARWIN or FREEBSD or OPENBSD or NETBSD
60 # See https://docs.python.org/3/library/platform.html#cross-platform
61 IS_64BITS = maxsize > 2**32
62 
63 if WINDOWS:
64     try:
65         if float(platform_lib.release()) >= 8.1:
66             LOOPBACK_NAME = "Microsoft KM-TEST Loopback Adapter"
67         else:
68             LOOPBACK_NAME = "Microsoft Loopback Adapter"
69     except ValueError:
70         LOOPBACK_NAME = "Microsoft Loopback Adapter"
71     # Will be different on Windows
72     LOOPBACK_INTERFACE = None
73 else:
74     uname = os.uname()
75     LOOPBACK_NAME = "lo" if LINUX else "lo0"
76     LOOPBACK_INTERFACE = LOOPBACK_NAME
77 
78 def parent_function():
79     return inspect.getouterframes(inspect.currentframe())
80
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/scapy/consts.py b/scapy/consts.py
--- a/scapy/consts.py
+++ b/scapy/consts.py
@@ -27,7 +27,7 @@
     MATPLOTLIB_DEFAULT_PLOT_KARGS = dict()
     log_loading.info("Can't import matplotlib. Won't be able to plot.")
 
-def test_pyx():
+def _test_pyx():
     """Returns if PyX is correctly installed or not"""
     try:
         with open(os.devnull, 'wb') as devnull:
@@ -39,7 +39,7 @@
 
 try:
     import pyx
-    if test_pyx():
+    if _test_pyx():
         PYX = 1
     else:
         log_loading.warning("PyX dependencies are not installed ! Please install TexLive or MikTeX.")

{"golden_diff": "diff --git a/scapy/consts.py b/scapy/consts.py\n--- a/scapy/consts.py\n+++ b/scapy/consts.py\n@@ -27,7 +27,7 @@\n     MATPLOTLIB_DEFAULT_PLOT_KARGS = dict()\n     log_loading.info(\"Can't import matplotlib. Won't be able to plot.\")\n \n-def test_pyx():\n+def _test_pyx():\n     \"\"\"Returns if PyX is correctly installed or not\"\"\"\n     try:\n         with open(os.devnull, 'wb') as devnull:\n@@ -39,7 +39,7 @@\n \n try:\n     import pyx\n-    if test_pyx():\n+    if _test_pyx():\n         PYX = 1\n     else:\n         log_loading.warning(\"PyX dependencies are not installed ! Please install TexLive or MikTeX.\")\n", "issue": "test_pyx problem\nI have a unit test that uses scapy library like this:\r\n```\r\n$ cat ut.py \r\nfrom scapy.all import *\r\n\r\ndef test_foo():\r\n    pass\r\n```\r\nThe problem is that testing framework (pytest) detects internal scapy function test_pyx as a test:\r\n```\r\nut.py::test_foo PASSED\r\nut.py::test_pyx <- venv/src/scapy/scapy/consts.py PASSED\r\n```\r\nThis is because test_pyx function from scapy/consts.py is unnecessarily imported from scapy.all\r\nand pytest treats all test_* functions as tests.\r\n\r\nScapy from current master branch.\r\n\r\n\n", "before_files": [{"content": "## This file is part of Scapy\n## See http://www.secdev.org/projects/scapy for more informations\n## Copyright (C) Philippe Biondi <phil@secdev.org>\n## This program is published under a GPLv2 license\n\nimport os, inspect\nfrom sys import platform, maxsize\nimport platform as platform_lib\nfrom scapy.error import *\n\nimport subprocess\n\ntry:\n    from matplotlib import get_backend as matplotlib_get_backend\n    import matplotlib.pyplot as plt\n    MATPLOTLIB = 1\n    if \"inline\" in matplotlib_get_backend():\n        MATPLOTLIB_INLINED = 1\n    else:\n        MATPLOTLIB_INLINED = 0\n    MATPLOTLIB_DEFAULT_PLOT_KARGS = {\"marker\": \"+\"}\n# RuntimeError to catch gtk \"Cannot open display\" error\nexcept (ImportError, RuntimeError):\n    plt = None\n    MATPLOTLIB = 0\n    MATPLOTLIB_INLINED = 0\n    MATPLOTLIB_DEFAULT_PLOT_KARGS = dict()\n    log_loading.info(\"Can't import matplotlib. Won't be able to plot.\")\n\ndef test_pyx():\n    \"\"\"Returns if PyX is correctly installed or not\"\"\"\n    try:\n        with open(os.devnull, 'wb') as devnull:\n            r = subprocess.check_call([\"pdflatex\", \"--version\"], stdout=devnull, stderr=subprocess.STDOUT)\n    except:\n        return False\n    else:\n        return r == 0\n\ntry:\n    import pyx\n    if test_pyx():\n        PYX = 1\n    else:\n        log_loading.warning(\"PyX dependencies are not installed ! Please install TexLive or MikTeX.\")\n        PYX = 0\nexcept ImportError:\n    log_loading.info(\"Can't import PyX. Won't be able to use psdump() or pdfdump().\")\n    PYX = 0\n\n\nLINUX = platform.startswith(\"linux\")\nOPENBSD = platform.startswith(\"openbsd\")\nFREEBSD = \"freebsd\" in platform\nNETBSD = platform.startswith(\"netbsd\")\nDARWIN = platform.startswith(\"darwin\")\nSOLARIS = platform.startswith(\"sunos\")\nWINDOWS = platform.startswith(\"win32\")\nBSD = DARWIN or FREEBSD or OPENBSD or NETBSD\n# See https://docs.python.org/3/library/platform.html#cross-platform\nIS_64BITS = maxsize > 2**32\n\nif WINDOWS:\n    try:\n        if float(platform_lib.release()) >= 8.1:\n            LOOPBACK_NAME = \"Microsoft KM-TEST Loopback Adapter\"\n        else:\n            LOOPBACK_NAME = \"Microsoft Loopback Adapter\"\n    except ValueError:\n        LOOPBACK_NAME = \"Microsoft Loopback Adapter\"\n    # Will be different on Windows\n    LOOPBACK_INTERFACE = None\nelse:\n    uname = os.uname()\n    LOOPBACK_NAME = \"lo\" if LINUX else \"lo0\"\n    LOOPBACK_INTERFACE = LOOPBACK_NAME\n\ndef parent_function():\n    return inspect.getouterframes(inspect.currentframe())\n", "path": "scapy/consts.py"}], "after_files": [{"content": "## This file is part of Scapy\n## See http://www.secdev.org/projects/scapy for more informations\n## Copyright (C) Philippe Biondi <phil@secdev.org>\n## This program is published under a GPLv2 license\n\nimport os, inspect\nfrom sys import platform, maxsize\nimport platform as platform_lib\nfrom scapy.error import *\n\nimport subprocess\n\ntry:\n    from matplotlib import get_backend as matplotlib_get_backend\n    import matplotlib.pyplot as plt\n    MATPLOTLIB = 1\n    if \"inline\" in matplotlib_get_backend():\n        MATPLOTLIB_INLINED = 1\n    else:\n        MATPLOTLIB_INLINED = 0\n    MATPLOTLIB_DEFAULT_PLOT_KARGS = {\"marker\": \"+\"}\n# RuntimeError to catch gtk \"Cannot open display\" error\nexcept (ImportError, RuntimeError):\n    plt = None\n    MATPLOTLIB = 0\n    MATPLOTLIB_INLINED = 0\n    MATPLOTLIB_DEFAULT_PLOT_KARGS = dict()\n    log_loading.info(\"Can't import matplotlib. Won't be able to plot.\")\n\ndef _test_pyx():\n    \"\"\"Returns if PyX is correctly installed or not\"\"\"\n    try:\n        with open(os.devnull, 'wb') as devnull:\n            r = subprocess.check_call([\"pdflatex\", \"--version\"], stdout=devnull, stderr=subprocess.STDOUT)\n    except:\n        return False\n    else:\n        return r == 0\n\ntry:\n    import pyx\n    if _test_pyx():\n        PYX = 1\n    else:\n        log_loading.warning(\"PyX dependencies are not installed ! Please install TexLive or MikTeX.\")\n        PYX = 0\nexcept ImportError:\n    log_loading.info(\"Can't import PyX. Won't be able to use psdump() or pdfdump().\")\n    PYX = 0\n\n\nLINUX = platform.startswith(\"linux\")\nOPENBSD = platform.startswith(\"openbsd\")\nFREEBSD = \"freebsd\" in platform\nNETBSD = platform.startswith(\"netbsd\")\nDARWIN = platform.startswith(\"darwin\")\nSOLARIS = platform.startswith(\"sunos\")\nWINDOWS = platform.startswith(\"win32\")\nBSD = DARWIN or FREEBSD or OPENBSD or NETBSD\n# See https://docs.python.org/3/library/platform.html#cross-platform\nIS_64BITS = maxsize > 2**32\n\nif WINDOWS:\n    try:\n        if float(platform_lib.release()) >= 8.1:\n            LOOPBACK_NAME = \"Microsoft KM-TEST Loopback Adapter\"\n        else:\n            LOOPBACK_NAME = \"Microsoft Loopback Adapter\"\n    except ValueError:\n        LOOPBACK_NAME = \"Microsoft Loopback Adapter\"\n    # Will be different on Windows\n    LOOPBACK_INTERFACE = None\nelse:\n    uname = os.uname()\n    LOOPBACK_NAME = \"lo\" if LINUX else \"lo0\"\n    LOOPBACK_INTERFACE = LOOPBACK_NAME\n\ndef parent_function():\n    return inspect.getouterframes(inspect.currentframe())\n", "path": "scapy/consts.py"}]}