Index: gi/__init__.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- gi/__init__.py	(date 1443950284000)
+++ gi/__init__.py	(date 1454754120000)
@@ -84,28 +84,56 @@
         )
 
 
-def require_version(namespace, version):
+def require_versions(requires):
+    """ Ensures the correct versions are loaded when importing `gi` modules.
+
+    :param requires: The names and versions of modules to require.
+    :type requires: dict
+    :raises ValueError: If module/version is already loaded, already required, or unavailable.
+    :raises TypeError: If `requires` is not a dict.
+
+    Example:
+
+        gi.require_version({'Gtk': '3.0', 'GLib': '2.0', 'Gio': '2.0'})
+
+    """
     repository = Repository.get_default()
 
-    if namespace in repository.get_loaded_namespaces():
-        loaded_version = repository.get_version(namespace)
-        if loaded_version != version:
-            raise ValueError('Namespace %s is already loaded with version %s' %
-                             (namespace, loaded_version))
+    if not isinstance(requires, dict):
+        raise TypeError(
+            'requires must be of type {0}, {1} given.'.format(type(dict), type(requires))
+        )
 
-    if namespace in _versions and _versions[namespace] != version:
-        raise ValueError('Namespace %s already requires version %s' %
-                         (namespace, _versions[namespace]))
+    for item_name, item_version in requires.items():
 
-    available_versions = repository.enumerate_versions(namespace)
+        if item_name in repository.get_loaded_namespaces():
+            loaded_version = repository.get_version(item_name)
+            if item_version != loaded_version:
+                raise ValueError(
+                    '{0} {1} is already loaded.'.format(item_name, loaded_version)
+                )
+
+        if item_name in _versions and _versions[item_name] != item_version:
+            raise ValueError(
+                '{0} {1} is already required.'.format(item_name, _versions[item_name])
+            )
+
+        available_versions = repository.enumerate_versions(item_name)
+
-    if not available_versions:
+        if not available_versions:
-        raise ValueError('Namespace %s not available' % namespace)
+            raise ValueError('{0} is not available'.format(item_name))
 
-    if version not in available_versions:
-        raise ValueError('Namespace %s not available for version %s' %
-                         (namespace, version))
+        if item_version not in available_versions:
+            raise ValueError('{0} {1} is not available.'.format(item_name, item_version))
 
-    _versions[namespace] = version
+        _versions[item_name] = item_version
+
+
+def require_version(namespace, version):
+    if not all([True for arg in [namespace, version] if isinstance(arg, str)]):
+        raise TypeError('namespace and version must be of type {0}'.format(type(str)))
+
+    require_versions({namespace: version})
 
 
 def get_required_version(namespace):
Index: tests/test_import_machinery.py
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- tests/test_import_machinery.py	(date 1443950284000)
+++ tests/test_import_machinery.py	(date 1454754120000)
@@ -3,10 +3,12 @@
 
 import sys
 import unittest
+import warnings
 
 import gi.overrides
 import gi.module
 import gi.importer
+from gi import PyGIWarning
 
 try:
     from gi.repository import Regress
@@ -134,17 +136,36 @@
     def test_require_version_warning(self):
         check = gi.importer._check_require_version
 
-        # make sure it doesn't fail at least
-        with check("GLib", 1):
-            from gi.repository import GLib
-            GLib
+        with check("Gdk", 3):
+            with warnings.catch_warnings(record=True) as warning:
+                from gi.repository import Gdk
+                _ = Gdk.Geometry()
+                self.assertTrue(issubclass(warning[0].category, PyGIWarning))
+                self.assertTrue('specifying a version first' in str(warning[0].message))
 
-        # make sure the exception propagates
-        with self.assertRaises(ImportError):
-            with check("InvalidGObjectRepositoryModuleName", 1):
-                from gi.repository import InvalidGObjectRepositoryModuleName
-                InvalidGObjectRepositoryModuleName
-
     def test_get_import_stacklevel(self):
         gi.importer.get_import_stacklevel(import_hook=True)
         gi.importer.get_import_stacklevel(import_hook=False)
+
+    def test_gi_require_versions(self):
+
+        gi.require_versions({'AppStreamGlib': '1.0', 'Gtk': '3.0', 'GLib': '2.0'})
+
+        # Test for properly raised exceptions
+        with self.assertRaises(ValueError) as context:
+            gi.require_versions({'Gtk', '3.0'})
+
+        exception_string = str(context.exception)
+        self.assertTrue('is already required' in exception_string)
+
+    def test_gi_require_version(self):
+        gi.require_version('Gtk', '3.0')
+
+        # Test for properly raised exceptions
+        with self.assertRaises(ValueError) as context:
+            gi.require_version('Gtk', '3.0')
+
+        exception_string = str(context.exception)
+        self.assertTrue('is already required' in exception_string)
+
+
