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):

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
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
 

pip install -e .[testing]
parse_log_pytest
pytest
pytest
apt-get update apt-get install -y gcc
3.9
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
coverage==7.8.0
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
hupper==1.12.1
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
mock==5.2.0
nose==1.3.7
nosexcover==1.0.11
packaging @ file:///croot/packaging_1734472117206/work
PasteDeploy==3.1.0
plaster==1.1.2
plaster-pastedeploy==1.0.1
pluggy @ file:///croot/pluggy_1733169602837/work
pyramid==2.0.2
-e git+https://github.com/pior/pyramid_useragent.git@ca27e28f2b19a2c68a8c3a4a555ee0420b0c382b#egg=pyramid_useragent
pytest @ file:///croot/pytest_1738938843180/work
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work
translationstring==1.4
ua-parser==1.0.1
ua-parser-builtins==0.18.0.post1
user-agents==2.2.0
venusian==3.1.1
WebOb==1.8.9
zope.deprecation==5.1
zope.interface==7.2

name: pyramid_useragent
channels:
  - defaults
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/r
  - conda-forge
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - ca-certificates=2025.2.25=h06a4308_0
  - exceptiongroup=1.2.0=py39h06a4308_0
  - iniconfig=1.1.1=pyhd3eb1b0_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.4.4=h6a678d5_1
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libstdcxx-ng=11.2.0=h1234567_1
  - ncurses=6.4=h6a678d5_0
  - openssl=3.0.16=h5eee18b_0
  - packaging=24.2=py39h06a4308_0
  - pip=25.0=py39h06a4308_0
  - pluggy=1.5.0=py39h06a4308_0
  - pytest=8.3.4=py39h06a4308_0
  - python=3.9.21=he870216_1
  - readline=8.2=h5eee18b_0
  - setuptools=75.8.0=py39h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - tomli=2.0.1=py39h06a4308_0
  - tzdata=2025a=h04d1e81_0
  - wheel=0.45.1=py39h06a4308_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - coverage==7.8.0
      - hupper==1.12.1
      - mock==5.2.0
      - nose==1.3.7
      - nosexcover==1.0.11
      - pastedeploy==3.1.0
      - plaster==1.1.2
      - plaster-pastedeploy==1.0.1
      - pyramid==2.0.2
      - translationstring==1.4
      - ua-parser==1.0.1
      - ua-parser-builtins==0.18.0.post1
      - user-agents==2.2.0
      - venusian==3.1.1
      - webob==1.8.9
      - zope-deprecation==5.1
      - zope-interface==7.2
prefix: /opt/conda/envs/pyramid_useragent

pyramid_useragent/tests.py::TestPyramidUserAgent::test_no_user_agent
pyramid_useragent/tests.py::TestPyramidUserAgent::test_components_list_order pyramid_useragent/tests.py::TestPyramidUserAgent::test_empty_user_agent pyramid_useragent/tests.py::TestPyramidUserAgent::test_maincomponent pyramid_useragent/tests.py::TestPyramidUserAgent::test_no_version pyramid_useragent/tests.py::TestPyramidUserAgent::test_value_none
pyramid_useragent/tests.py::TestPyramidUserAgent::test_components_comment pyramid_useragent/tests.py::TestPyramidUserAgent::test_get_user_agent_classified pyramid_useragent/tests.py::TestPyramidUserAgent::test_get_user_agent_parsed pyramid_useragent/tests.py::TestPyramidUserAgent::test_safety
pyramid_useragent/__init__.py
pyramid_useragent/__init__.py