nebius/SWE-bench-extra huggingface dataset:
Repository: pior/pyramid_useragent

Issue:
Fails if request.user_agent is None
Anonymous report on Bitbucket:

> In my unit tests using WebTest, request.user_agent comes through as None. This is probably the behavior of pyramid when the User-Agent header is not provided.

https://bitbucket.org/pior/pyramid_useragent/issues/3/fails-if-requestuser_agent-is-none

Comments:

Patch:
diff --git a/pyramid_useragent/__init__.py b/pyramid_useragent/__init__.py
index a06e6d0..c6a71ac 100644
--- a/pyramid_useragent/__init__.py
+++ b/pyramid_useragent/__init__.py
@@ -27,7 +27,7 @@ def get_user_agent_parsed(request):
     return UserAgent(request.user_agent)
 
 def get_user_agent_classified(request):
-    return UserAgentClassifier(request.user_agent)
+    return UserAgentClassifier(request.user_agent or '')
 
 
 class UserAgentComponent(object):


Test patch:
diff --git a/pyramid_useragent/tests.py b/pyramid_useragent/tests.py
index 1bb7104..4c771a5 100644
--- a/pyramid_useragent/tests.py
+++ b/pyramid_useragent/tests.py
@@ -28,6 +28,15 @@ class TestPyramidUserAgent(unittest.TestCase):
         self.assertIsInstance(resp, UserAgentClassifier)
         self.assertTrue(resp.is_mobile)
 
+    def test_no_user_agent(self):
+        from pyramid_useragent import (get_user_agent_classified, UserAgentClassifier)
+
+        request = mock.Mock()
+        request.user_agent = None
+
+        resp = get_user_agent_classified(request)
+        self.assertIsInstance(resp, UserAgentClassifier)
+
     def test_safety(self):
         from pyramid_useragent import UserAgent