code: def test_versioned():
      with TemporaryDirectory() as tmpdir:
          with pytest.raises(DataError):
              VersionedDatasource(tmpdir)
          tmpfile = pjoin(tmpdir, "config.ini")
          # ini file, but wrong section
          with open(tmpfile, "w") as fobj:
              fobj.write("[SOMESECTION]\n")
              fobj.write("version = 0.1\n")
          with pytest.raises(DataError):
              VersionedDatasource(tmpdir)
          # ini file, but right section, wrong key
          with open(tmpfile, "w") as fobj:
              fobj.write("[DEFAULT]\n")
              fobj.write("somekey = 0.1\n")
          with pytest.raises(DataError):
              VersionedDatasource(tmpdir)
          # ini file, right section and key
          with open(tmpfile, "w") as fobj:
              fobj.write("[DEFAULT]\n")
              fobj.write("version = 0.1\n")
          vds = VersionedDatasource(tmpdir)
          assert vds.version == "0.1"
          assert vds.version_no == 0.1
          assert vds.major_version == 0
          assert vds.minor_version == 1
          assert vds.get_filename("config.ini") == tmpfile
          # ini file, right section and key, funny value
          with open(tmpfile, "w") as fobj:
              fobj.write("[DEFAULT]\n")
              fobj.write("version = 0.1.2.dev\n")
          vds = VersionedDatasource(tmpdir)
          assert vds.version == "0.1.2.dev"
          assert vds.version_no == 0.1
          assert vds.major_version == 0
          assert vds.minor_version == 1
  
file_path: nibabel/nibabel/tests/test_data.py
imports: import os
  import sys
  import tempfile
  from os import environ
  from os.path import join
  from tempfile import TemporaryDirectory
  import pytest
  from ..None import data
  from ..data import Bomber, DataError, Datasource, VersionedDatasource, _cfg_value, datasource_or_bomber, find_data_dir, get_data_path, make_datasource
  from .test_environment import DATA_KEY, USER_KEY, with_environment
label_desc: Use image node_id 3 for calling a global function with example usage: test_versioned() without return types