summaryrefslogtreecommitdiff
path: root/bs4/tests/test_soup.py
diff options
context:
space:
mode:
Diffstat (limited to 'bs4/tests/test_soup.py')
-rw-r--r--bs4/tests/test_soup.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/bs4/tests/test_soup.py b/bs4/tests/test_soup.py
index f21edfa..0603ce7 100644
--- a/bs4/tests/test_soup.py
+++ b/bs4/tests/test_soup.py
@@ -3,6 +3,7 @@
from pdb import set_trace
import logging
+import os
import unittest
import sys
import tempfile
@@ -291,6 +292,21 @@ class TestWarnings(SoupTest):
soup = self.soup(filename)
self.assertEqual([], w)
+ def test_directory_warning(self):
+ try:
+ filename = tempfile.mkdtemp()
+ with warnings.catch_warnings(record=True) as w:
+ soup = self.soup(filename)
+ warning = self._assert_warning(w, MarkupResemblesLocatorWarning)
+ self.assertTrue("looks like a directory" in str(warning.message))
+ finally:
+ os.rmdir(filename)
+
+ # The directory no longer exists, so Beautiful Soup will no longer issue the warning.
+ with warnings.catch_warnings(record=True) as w:
+ soup = self.soup(filename)
+ self.assertEqual([], w)
+
def test_url_warning_with_bytes_url(self):
with warnings.catch_warnings(record=True) as warning_list:
soup = self.soup(b"http://www.crummybytes.com/")