diff --git a/gabbi/runner.py b/gabbi/runner.py
index ac98dea..9f45351 100644
--- a/gabbi/runner.py
+++ b/gabbi/runner.py
@@ -14,6 +14,7 @@
 
 import argparse
 from importlib import import_module
+import os
 import sys
 import unittest
 
@@ -84,8 +85,9 @@ def run():
     else:
         for input_file in input_files:
             with open(input_file, 'r') as fh:
+                data_dir = os.path.dirname(input_file)
                 success = run_suite(fh, handler_objects, host, port,
-                                    prefix, force_ssl, failfast)
+                                    prefix, force_ssl, failfast, data_dir)
             if not failure:  # once failed, this is considered immutable
                 failure = not success
             if failure and failfast:
@@ -95,7 +97,7 @@ def run():
 
 
 def run_suite(handle, handler_objects, host, port, prefix, force_ssl=False,
-              failfast=False):
+              failfast=False, data_dir='.'):
     """Run the tests from the YAML in handle."""
     data = utils.load_yaml(handle)
     if force_ssl:
@@ -106,7 +108,7 @@ def run_suite(handle, handler_objects, host, port, prefix, force_ssl=False,
 
     loader = unittest.defaultTestLoader
     test_suite = suitemaker.test_suite_from_dict(
-        loader, 'input', data, '.', host, port, None, None, prefix=prefix,
+        loader, 'input', data, data_dir, host, port, None, None, prefix=prefix,
         handlers=handler_objects)
 
     result = ConciseTestRunner(

Data <@filename isn't relative to the YAML file
The [docs say](https://gabbi.readthedocs.io/en/latest/format.html#data):

> If the value is a string that begins with <@ then the rest of the string is treated as the name of a file to be loaded from the same directory as the YAML file. 

But I haven't found it works like this unless I cd into the directory containing the yaml file.

`_load_data_file` says:
```python
path = os.path.join(self.test_directory, os.path.basename(filename))
```
this does a few things:
- makes the path begin with `self.test_directory` (defaults to `.`, the current working directory)
- disguards any folders in the <@ `filename` path
- appends `filename`

This means, if I'm in `/`, and I have a test that says `data: <@cake.jpg`, I cannot run my tests as advised in the docs:
`gabbi-run -- /my/test.yaml /my/other.yaml`

`FileNotFoundError: [Errno 2] No such file or directory: './cake.jpg'`

So in our test running script, we have to start with `cd tests/`.

My preference, would be to make the path relative to the location of the yaml file. That way, I can run my tests from whatever directory.

Obviously this isn't possible when redirecting with `<` as the filename is never seen by gabbi. So I'm happy is discuss other ideas.

---

Furthermore I can't keep my test data in a child directory, unless I cd into that directory like:
```shell
cd yaml_tests/test_data
gabbi-run -- ../test_things.yaml
```

So for that reason, I'd like to allow directories like `<@test_data/filename.txt` to be included in the path.

---

Happy to write the patch, if we come up with an approach here.
diff --git a/gabbi/tests/gabbits_runner/subdir/sample.json b/gabbi/tests/gabbits_runner/subdir/sample.json
new file mode 100644
index 0000000..ddbce20
--- /dev/null
+++ b/gabbi/tests/gabbits_runner/subdir/sample.json
@@ -0,0 +1,1 @@
+{"items": {"house": "blue"}}
diff --git a/gabbi/tests/gabbits_runner/test_data.yaml b/gabbi/tests/gabbits_runner/test_data.yaml
new file mode 100644
index 0000000..35d056a
--- /dev/null
+++ b/gabbi/tests/gabbits_runner/test_data.yaml
@@ -0,0 +1,8 @@
+tests:
+
+- name: POST data from file
+  verbose: true
+  POST: /
+  request_headers:
+    content-type: application/json
+  data: <@subdir/sample.json
diff --git a/gabbi/tests/test_runner.py b/gabbi/tests/test_runner.py
index bf882ab..1b86235 100644
--- a/gabbi/tests/test_runner.py
+++ b/gabbi/tests/test_runner.py
@@ -22,6 +22,7 @@ from wsgi_intercept.interceptor import Urllib3Interceptor
 
 from gabbi import exception
 from gabbi.handlers import base
+from gabbi.handlers.jsonhandler import JSONHandler
 from gabbi import runner
 from gabbi.tests.simple_wsgi import SimpleWsgi
 
@@ -249,6 +250,28 @@ class RunnerTest(unittest.TestCase):
         self.assertIn('{\n', output)
         self.assertIn('}\n', output)
 
+    def test_data_dir_good(self):
+        """Confirm that data dir is the test file's dir."""
+        sys.argv = ['gabbi-run', 'http://%s:%s/foo' % (self.host, self.port)]
+
+        sys.argv.append('--')
+        sys.argv.append('gabbi/tests/gabbits_runner/test_data.yaml')
+        with self.server():
+            try:
+                runner.run()
+            except SystemExit as err:
+                self.assertSuccess(err)
+
+        # Compare the verbose output of tests with pretty printed
+        # data.
+        with open('gabbi/tests/gabbits_runner/subdir/sample.json') as data:
+            data = JSONHandler.loads(data.read())
+            expected_string = JSONHandler.dumps(data, pretty=True)
+
+        sys.stdout.seek(0)
+        output = sys.stdout.read()
+        self.assertIn(expected_string, output)
+
     def assertSuccess(self, exitError):
         errors = exitError.args[0]
         if errors:

pip install -e .
parse_log_pytest
requirements.txt
pytest mock testrepository coverage hacking sphinx
3.5
requirements.txt
pytest --no-header -rA --tb=line --color=no -p no:cacheprovider -W ignore::DeprecationWarning
alabaster==0.7.13
attrs==22.2.0
Babel==2.11.0
certifi==2021.5.30
charset-normalizer==2.0.12
colorama==0.4.5
coverage==6.2
decorator==5.1.1
docutils==0.18.1
extras==1.0.0
fixtures==4.0.1
flake8==3.8.4
-e git+https://github.com/cdent/gabbi.git@07dc4913eb980dd4a4a6130abfd708a39235d7f2#egg=gabbi
hacking==4.1.0
idna==3.10
imagesize==1.4.1
importlib-metadata==4.8.3
iniconfig==1.1.1
iso8601==1.1.0
Jinja2==3.0.3
jsonpath-rw==1.4.0
jsonpath-rw-ext==1.2.2
MarkupSafe==2.0.1
mccabe==0.6.1
mock==5.2.0
packaging==21.3
pbr==6.1.1
pluggy==1.0.0
ply==3.11
py==1.11.0
pycodestyle==2.6.0
pyflakes==2.2.0
Pygments==2.14.0
pyparsing==3.1.4
pytest==7.0.1
python-subunit==1.4.2
pytz==2025.2
PyYAML==6.0.1
requests==2.27.1
six==1.17.0
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
testrepository==0.0.21
testtools==2.6.0
tomli==1.2.3
typing_extensions==4.1.1
urllib3==1.26.20
wsgi_intercept==1.13.1
zipp==3.6.0

name: gabbi
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
  - certifi=2021.5.30=py36h06a4308_0
  - ld_impl_linux-64=2.40=h12ee557_0
  - libffi=3.3=he6710b0_2
  - 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=1.1.1w=h7f8727e_0
  - pip=21.2.2=py36h06a4308_0
  - python=3.6.13=h12debd9_1
  - readline=8.2=h5eee18b_0
  - setuptools=58.0.4=py36h06a4308_0
  - sqlite=3.45.3=h5eee18b_0
  - tk=8.6.14=h39e8969_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - xz=5.6.4=h5eee18b_1
  - zlib=1.2.13=h5eee18b_1
  - pip:
      - alabaster==0.7.13
      - attrs==22.2.0
      - babel==2.11.0
      - charset-normalizer==2.0.12
      - colorama==0.4.5
      - coverage==6.2
      - decorator==5.1.1
      - docutils==0.18.1
      - extras==1.0.0
      - fixtures==4.0.1
      - flake8==3.8.4
      - hacking==4.1.0
      - idna==3.10
      - imagesize==1.4.1
      - importlib-metadata==4.8.3
      - iniconfig==1.1.1
      - iso8601==1.1.0
      - jinja2==3.0.3
      - jsonpath-rw==1.4.0
      - jsonpath-rw-ext==1.2.2
      - markupsafe==2.0.1
      - mccabe==0.6.1
      - mock==5.2.0
      - packaging==21.3
      - pbr==6.1.1
      - pluggy==1.0.0
      - ply==3.11
      - py==1.11.0
      - pycodestyle==2.6.0
      - pyflakes==2.2.0
      - pygments==2.14.0
      - pyparsing==3.1.4
      - pytest==7.0.1
      - python-subunit==1.4.2
      - pytz==2025.2
      - pyyaml==6.0.1
      - requests==2.27.1
      - six==1.17.0
      - snowballstemmer==2.2.0
      - sphinx==5.3.0
      - sphinxcontrib-applehelp==1.0.2
      - sphinxcontrib-devhelp==1.0.2
      - sphinxcontrib-htmlhelp==2.0.0
      - sphinxcontrib-jsmath==1.0.1
      - sphinxcontrib-qthelp==1.0.3
      - sphinxcontrib-serializinghtml==1.1.5
      - testrepository==0.0.21
      - testtools==2.6.0
      - tomli==1.2.3
      - typing-extensions==4.1.1
      - urllib3==1.26.20
      - wsgi-intercept==1.13.1
      - zipp==3.6.0
prefix: /opt/conda/envs/gabbi

gabbi/tests/test_runner.py::RunnerTest::test_data_dir_good
gabbi/tests/test_runner.py::RunnerTest::test_custom_response_handler gabbi/tests/test_runner.py::RunnerTest::test_exit_code gabbi/tests/test_runner.py::RunnerTest::test_input_files gabbi/tests/test_runner.py::RunnerTest::test_target_url_parsing gabbi/tests/test_runner.py::RunnerTest::test_target_url_parsing_standard_port gabbi/tests/test_runner.py::RunnerTest::test_verbose_output_formatting
gabbi/runner.py
gabbi/runner.py