prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Make event test more specific
                @matmair [this CI failure](https://github.com/inventree/InvenTree/actions/runs/5259899543/jobs/9506168595?pr=4732) is the last in the current batch of weird ones. I'm seeing it on multiple PRs, about 50% of the time.
  
  Here's the failing line:
  
  https://github.com/inventree/InvenTree/blob/c8365ccd0c9371ea4d127fe616e0029f35b3c19c/InvenTree/plugin/samples/event/test_event_sample.py#L27
  
  Sometimes, `cm.warning.args[0]` returns an "unclosed file object", rather than a string. Any ideas?
  
  _Originally posted by @SchrodingersGat in https://github.com/inventree/InvenTree/issues/4732#issuecomment-1590219025_
              
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `InvenTree/plugin/samples/event/event_sample.py`
  Content:
  ```
  1 """Sample plugin which responds to events."""
  2 
  3 import warnings
  4 
  5 from django.conf import settings
  6 
  7 from plugin import InvenTreePlugin
  8 from plugin.mixins import EventMixin
  9 
  10 
  11 class EventPluginSample(EventMixin, InvenTreePlugin):
  12     """A sample plugin which provides supports for triggered events."""
  13 
  14     NAME = "EventPlugin"
  15     SLUG = "sampleevent"
  16     TITLE = "Triggered Events"
  17 
  18     def process_event(self, event, *args, **kwargs):
  19         """Custom event processing."""
  20         print(f"Processing triggered event: '{event}'")
  21         print("args:", str(args))
  22         print("kwargs:", str(kwargs))
  23 
  24         # Issue warning that we can test for
  25         if settings.PLUGIN_TESTING:
  26             warnings.warn(f'Event `{event}` triggered', stacklevel=2)
  27
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/InvenTree/plugin/samples/event/event_sample.py b/InvenTree/plugin/samples/event/event_sample.py
  --- a/InvenTree/plugin/samples/event/event_sample.py
  +++ b/InvenTree/plugin/samples/event/event_sample.py
  @@ -1,12 +1,14 @@
   """Sample plugin which responds to events."""
   
  -import warnings
  +import logging
   
   from django.conf import settings
   
   from plugin import InvenTreePlugin
   from plugin.mixins import EventMixin
   
  +logger = logging.getLogger('inventree')
  +
   
   class EventPluginSample(EventMixin, InvenTreePlugin):
       """A sample plugin which provides supports for triggered events."""
  @@ -23,4 +25,4 @@
   
           # Issue warning that we can test for
           if settings.PLUGIN_TESTING:
  -            warnings.warn(f'Event `{event}` triggered', stacklevel=2)
  +            logger.debug(f'Event `{event}` triggered in sample plugin')
  
verification_info: {"golden_diff": "diff --git a/InvenTree/plugin/samples/event/event_sample.py b/InvenTree/plugin/samples/event/event_sample.py\n--- a/InvenTree/plugin/samples/event/event_sample.py\n+++ b/InvenTree/plugin/samples/event/event_sample.py\n@@ -1,12 +1,14 @@\n \"\"\"Sample plugin which responds to events.\"\"\"\n \n-import warnings\n+import logging\n \n from django.conf import settings\n \n from plugin import InvenTreePlugin\n from plugin.mixins import EventMixin\n \n+logger = logging.getLogger('inventree')\n+\n \n class EventPluginSample(EventMixin, InvenTreePlugin):\n     \"\"\"A sample plugin which provides supports for triggered events.\"\"\"\n@@ -23,4 +25,4 @@\n \n         # Issue warning that we can test for\n         if settings.PLUGIN_TESTING:\n-            warnings.warn(f'Event `{event}` triggered', stacklevel=2)\n+            logger.debug(f'Event `{event}` triggered in sample plugin')\n", "issue": "Make event test more specific\n              @matmair [this CI failure](https://github.com/inventree/InvenTree/actions/runs/5259899543/jobs/9506168595?pr=4732) is the last in the current batch of weird ones. I'm seeing it on multiple PRs, about 50% of the time.\r\n\r\nHere's the failing line:\r\n\r\nhttps://github.com/inventree/InvenTree/blob/c8365ccd0c9371ea4d127fe616e0029f35b3c19c/InvenTree/plugin/samples/event/test_event_sample.py#L27\r\n\r\nSometimes, `cm.warning.args[0]` returns an \"unclosed file object\", rather than a string. Any ideas?\r\n\r\n_Originally posted by @SchrodingersGat in https://github.com/inventree/InvenTree/issues/4732#issuecomment-1590219025_\r\n            \n", "before_files": [{"content": "\"\"\"Sample plugin which responds to events.\"\"\"\n\nimport warnings\n\nfrom django.conf import settings\n\nfrom plugin import InvenTreePlugin\nfrom plugin.mixins import EventMixin\n\n\nclass EventPluginSample(EventMixin, InvenTreePlugin):\n    \"\"\"A sample plugin which provides supports for triggered events.\"\"\"\n\n    NAME = \"EventPlugin\"\n    SLUG = \"sampleevent\"\n    TITLE = \"Triggered Events\"\n\n    def process_event(self, event, *args, **kwargs):\n        \"\"\"Custom event processing.\"\"\"\n        print(f\"Processing triggered event: '{event}'\")\n        print(\"args:\", str(args))\n        print(\"kwargs:\", str(kwargs))\n\n        # Issue warning that we can test for\n        if settings.PLUGIN_TESTING:\n            warnings.warn(f'Event `{event}` triggered', stacklevel=2)\n", "path": "InvenTree/plugin/samples/event/event_sample.py"}], "after_files": [{"content": "\"\"\"Sample plugin which responds to events.\"\"\"\n\nimport logging\n\nfrom django.conf import settings\n\nfrom plugin import InvenTreePlugin\nfrom plugin.mixins import EventMixin\n\nlogger = logging.getLogger('inventree')\n\n\nclass EventPluginSample(EventMixin, InvenTreePlugin):\n    \"\"\"A sample plugin which provides supports for triggered events.\"\"\"\n\n    NAME = \"EventPlugin\"\n    SLUG = \"sampleevent\"\n    TITLE = \"Triggered Events\"\n\n    def process_event(self, event, *args, **kwargs):\n        \"\"\"Custom event processing.\"\"\"\n        print(f\"Processing triggered event: '{event}'\")\n        print(\"args:\", str(args))\n        print(\"kwargs:\", str(kwargs))\n\n        # Issue warning that we can test for\n        if settings.PLUGIN_TESTING:\n            logger.debug(f'Event `{event}` triggered in sample plugin')\n", "path": "InvenTree/plugin/samples/event/event_sample.py"}]}