diff --git a/.travis.yml b/.travis.yml
index e1b9f62..0b6f2c8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -10,7 +10,7 @@ python:
   - "nightly"
 # command to install dependencies
 install:
-  - pip install pydbg
+  - pip install -e .
 # command to run tests
 script:
   - pytest -vv
diff --git a/pydbg.py b/pydbg.py
index 3695ef8..a5b06df 100644
--- a/pydbg.py
+++ b/pydbg.py
@@ -27,7 +27,10 @@ def dbg(exp):
     for i in reversed(inspect.stack()):
         if "dbg" in i.code_context[0]:
             var_name = i.code_context[0][
-                i.code_context[0].find("(") + 1 : i.code_context[0].find(")")
+                i.code_context[0].find("(")
+                + 1 : len(i.code_context[0])
+                - 1
+                - i.code_context[0][::-1].find(")")
             ]
             print(f"[{i.filename}:{i.lineno}] {var_name} = {exp}")
             break

Parentheses aren't displayed correctly for functions
The closing parentheses around the function call is missing.
```
In [19]: def add(x, y):
    ...:     z = x + y
    ...:     return z
    ...:

In [20]: dbg(add(1, 2))
[<ipython-input-20-ac7b28727082>:1] add(1, 2 = 3
```
diff --git a/tests/test_pydbg.py b/tests/test_pydbg.py
index 5b12508..bf91ea4 100644
--- a/tests/test_pydbg.py
+++ b/tests/test_pydbg.py
@@ -4,9 +4,6 @@ from pydbg import dbg
 from contextlib import redirect_stdout
 
 
-def something():
-    pass
-
 cwd = os.getcwd()
 
 def test_variables():
@@ -23,12 +20,19 @@ def test_variables():
         dbg(strType)
         dbg(boolType)
         dbg(NoneType)
+        dbg(add(1, 2))
 
-    want = f"""[{cwd}/tests/test_pydbg.py:21] intType = 2
-[{cwd}/tests/test_pydbg.py:22] floatType = 2.1
-[{cwd}/tests/test_pydbg.py:23] strType = mystring
-[{cwd}/tests/test_pydbg.py:24] boolType = True
-[{cwd}/tests/test_pydbg.py:25] NoneType = None
+    want = f"""[{cwd}/tests/test_pydbg.py:18] intType = 2
+[{cwd}/tests/test_pydbg.py:19] floatType = 2.1
+[{cwd}/tests/test_pydbg.py:20] strType = mystring
+[{cwd}/tests/test_pydbg.py:21] boolType = True
+[{cwd}/tests/test_pydbg.py:22] NoneType = None
+[{cwd}/tests/test_pydbg.py:23] add(1, 2) = 3
 """
 
-    assert out.getvalue() == want
+    assert out.getvalue()  == want
+
+
+def add(x, y):
+    return x + y
+

pip install -e .
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
exceptiongroup @ file:///croot/exceptiongroup_1706031385326/work
iniconfig @ file:///home/linux1/recipes/ci/iniconfig_1610983019677/work
packaging @ file:///croot/packaging_1734472117206/work
pluggy @ file:///croot/pluggy_1733169602837/work
-e git+https://github.com/tylerwince/pydbg.git@e29ce20677f434dcf302c2c6f7bd872d26d4f13b#egg=pydbg
pytest @ file:///croot/pytest_1738938843180/work
tomli @ file:///opt/conda/conda-bld/tomli_1657175507142/work

name: pydbg
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
prefix: /opt/conda/envs/pydbg

tests/test_pydbg.py::test_variables
pydbg.py .travis.yml
pydbg.py .travis.yml