Repository: airbrake/pybrake

Issue:
[SITE_PACKAGES] -> /SITE_PACKAGES
https://github.com/airbrake/pybrake/blob/master/pybrake/notifier.py#L298

Discussion:
vmihailenco: Add a test

Patch:
diff --git a/pybrake/notifier.py b/pybrake/notifier.py
index 9218c51..c673108 100644
--- a/pybrake/notifier.py
+++ b/pybrake/notifier.py
@@ -295,7 +295,7 @@ class Notifier:
             needed = "/site-packages/"
             ind = s.find(needed)
             if ind > -1:
-                s = "[SITE_PACKAGES]/" + s[ind + len(needed) :]
+                s = "/SITE_PACKAGES/" + s[ind + len(needed) :]
                 return s
 
         s = s.replace(self._context["rootDirectory"], "/PROJECT_ROOT")


Test patch:
diff --git a/pybrake/test_notifier.py b/pybrake/test_notifier.py
index e7bc2d9..8774ef8 100644
--- a/pybrake/test_notifier.py
+++ b/pybrake/test_notifier.py
@@ -205,3 +205,9 @@ def _test_rate_limited():
 
     notice = future.result()
     assert notice["error"] == "IP is rate limited"
+
+def test_clean_filename():
+    notifier = Notifier()
+
+    filename = notifier._clean_filename("home/lib/python3.6/site-packages/python.py")
+    assert filename == "/SITE_PACKAGES/python.py"