summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@canonical.com>2023-03-14 10:43:30 +0000
committerGitHub <noreply@github.com>2023-03-14 10:43:30 +0000
commit3eda708b8a94192c34291cbc728ea9c01ed825b1 (patch)
tree445369460a6b7130c7e98eef016da9703b0d9dac
parent89ed130cf089a448b6d4492d5a4df9d6aecb9d23 (diff)
parent54ea8f2c53155b27e08b77a4d7080188c629bb3a (diff)
downloadtesttools-3eda708b8a94192c34291cbc728ea9c01ed825b1.tar.gz
Merge pull request #340 from mtreinish/no-more-cgi
Replace deprecated `cgi` module usage with `email`
-rw-r--r--testtools/testresult/real.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/testtools/testresult/real.py b/testtools/testresult/real.py
index 8c7f372..d5efad2 100644
--- a/testtools/testresult/real.py
+++ b/testtools/testresult/real.py
@@ -22,8 +22,8 @@ __all__ = [
'TimestampingStreamResult',
]
-import cgi
import datetime
+import email
import math
from operator import methodcaller
import sys
@@ -759,7 +759,10 @@ def _make_content_type(mime_type=None):
if mime_type is None:
mime_type = 'application/octet-stream'
- full_type, parameters = cgi.parse_header(mime_type)
+ msg = email.message.EmailMessage()
+ msg['content-type'] = mime_type
+
+ full_type, parameters = msg.get_content_type(), dict(msg['content-type'].params)
# Ensure any wildcards are valid.
if full_type == '*':
full_type = '*/*'