From e780a611a6925dc9db4fe9addaa31d01b8b35cfb Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Feb 28 2018 13:19:29 +0000
Subject: [PATCH 1/9] make internal_dev_setup an option in getMockConfig


---

diff --git a/koji/__init__.py b/koji/__init__.py
index 192f51b..1c593c8 100644
--- a/koji/__init__.py
+++ b/koji/__init__.py
@@ -1538,13 +1538,17 @@ name=build
     parts.append("\n")
 
     if bind_opts:
-        # This line is REQUIRED for mock to work if bind_opts defined.
-        parts.append("config_opts['internal_dev_setup'] = False\n")
+        # disable internal_dev_setup unless opts explicitly say otherwise
+        opts.setdefault('internal_dev_setup', False)
         for key in bind_opts.keys():
             for mnt_src, mnt_dest in six.iteritems(bind_opts.get(key)):
                 parts.append("config_opts['plugin_conf']['bind_mount_opts'][%r].append((%r, %r))\n" % (key, mnt_src, mnt_dest))
         parts.append("\n")
 
+    if 'internal_dev_setup' in opts:
+        parts.append("config_opts['internal_dev_setup'] = %r\n"
+                % bool(opts['internal_dev_setup']))
+
     for key, value in six.iteritems(macros):
         parts.append("config_opts['macros'][%r] = %r\n" % (key, value))
     parts.append("\n")

From 113ddea6f055cc193062fccd0f345ea0dccab78d Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Feb 28 2018 13:19:29 +0000
Subject: [PATCH 2/9] internal_dev_setup option for BuildRoot class


---

diff --git a/builder/kojid b/builder/kojid
index 26fbc6e..25cb923 100755
--- a/builder/kojid
+++ b/builder/kojid
@@ -181,7 +181,8 @@ class BuildRoot(object):
         self.config = self.session.getBuildConfig(self.tag_id, event=self.event_id)
 
     def _new(self, tag, arch, task_id, repo_id=None, install_group='build',
-             setup_dns=False, bind_opts=None, maven_opts=None, maven_envs=None, deps=None):
+             setup_dns=False, bind_opts=None, maven_opts=None, maven_envs=None,
+             deps=None, internal_dev_setup=None):
         """Create a brand new repo"""
         if not repo_id:
             raise koji.BuildrootError("A repo id must be provided")
@@ -223,6 +224,7 @@ class BuildRoot(object):
         self.maven_opts = maven_opts
         self.maven_envs = maven_envs
         self.deps = deps
+        self.internal_dev_setup = internal_dev_setup
         self._writeMockConfig()
 
     def _writeMockConfig(self):
@@ -247,6 +249,8 @@ class BuildRoot(object):
         opts['target_arch'] = self.target_arch
         if 'mock.package_manager' in self.config['extra']:
             opts['package_manager'] = self.config['extra']['mock.package_manager']
+        if self.internal_dev_setup is not None:
+            opts['internal_dev_setup'] = bool(self.internal_dev_setup)
         output = koji.genMockConfig(self.name, self.br_arch, managed=True, **opts)
 
         #write config

From 30749fa2d04752a46a3614d6caca371d1d0e8df7 Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Feb 28 2018 13:19:29 +0000
Subject: [PATCH 3/9] add internal_dev_setup option to runroot plugin


---

diff --git a/plugins/builder/runroot.py b/plugins/builder/runroot.py
index 373e880..777a04d 100644
--- a/plugins/builder/runroot.py
+++ b/plugins/builder/runroot.py
@@ -55,8 +55,14 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
            'safe_roots': [],
            'path_subs': [],
            'paths': [],
+           'internal_dev_setup': None,
         }
 
+        # main options
+        if cp.has_option('runroot', 'internal_dev_setup'):
+            self.config['internal_dev_setup'] = cp.getboolean('runroot', 'internal_dev_setup')
+
+        # path options
         if cp.has_option('paths', 'default_mounts'):
             self.config['default_mounts'] = cp.get('paths', 'default_mounts').split(',')
         if cp.has_option('paths', 'safe_roots'):
@@ -149,7 +155,9 @@ class RunRootTask(koji.tasks.BaseTaskHandler):
                                            arglist=[root, None, None],
                                            parent=self.id)
             repo_info = self.wait(task_id)[task_id]
-        broot = BuildRoot(self.session, self.options, root, br_arch, self.id, repo_id=repo_info['id'], setup_dns=True)
+        broot = BuildRoot(self.session, self.options, root, br_arch, self.id,
+                repo_id=repo_info['id'], setup_dns=True,
+                internal_dev_setup=self.config['internal_dev_setup'])
         broot.workdir = self.workdir
         broot.init()
         rootdir = broot.rootdir()

From cfca804acd9f7c2025c00c634d552d925b52183a Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Feb 28 2018 13:19:29 +0000
Subject: [PATCH 4/9] fix unit test


---

diff --git a/tests/test_plugins/test_runroot_builder.py b/tests/test_plugins/test_runroot_builder.py
index 21ffc12..426ad35 100644
--- a/tests/test_plugins/test_runroot_builder.py
+++ b/tests/test_plugins/test_runroot_builder.py
@@ -327,6 +327,7 @@ class TestHandler(unittest.TestCase):
         options.topurls = None
         self.t = runroot.RunRootTask(123, 'runroot', {}, self.session, options)
         self.t.config['default_mounts'] = ['default_mount']
+        self.t.config['internal_dev_setup'] = None
         self.t.do_mounts = mock.MagicMock()
         self.t.do_extra_mounts = mock.MagicMock()
         self.t.undo_mounts = mock.MagicMock()
@@ -370,7 +371,8 @@ class TestHandler(unittest.TestCase):
         self.session.repoInfo.assert_called_once_with(1, strict=True)
         self.session.host.subtask.assert_not_called()
         runroot.BuildRoot.assert_called_once_with(self.session, self.t.options,
-                'tag_name', 'x86_64', self.t.id, repo_id=1, setup_dns=True)
+                'tag_name', 'x86_64', self.t.id, repo_id=1, setup_dns=True,
+                internal_dev_setup=None)
         os_system.assert_called_once()
         self.session.host.setBuildRootState.assert_called_once_with(678, 'BUILDING')
         self.br.mock.assert_has_calls([

From c7e16a993dd7fa911cbb689754a8652cdfd944f4 Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Feb 28 2018 17:22:05 +0000
Subject: [PATCH 5/9] basic unit test for genMockConfig


---

diff --git a/tests/test_lib/__init__.py b/tests/test_lib/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/tests/test_lib/__init__.py
diff --git a/tests/test_lib/data/mock/simple.json b/tests/test_lib/data/mock/simple.json
new file mode 100644
index 0000000..10ab345
--- /dev/null
+++ b/tests/test_lib/data/mock/simple.json
@@ -0,0 +1,8 @@
+{
+    "name": "ROOTNAME",
+    "arch": "x86_64",
+    "managed": false,
+    "repoid": 99,
+    "tag_name": "TAG",
+    "opts": {}
+}
diff --git a/tests/test_lib/data/mock/simple.out b/tests/test_lib/data/mock/simple.out
new file mode 100644
index 0000000..9759669
--- /dev/null
+++ b/tests/test_lib/data/mock/simple.out
@@ -0,0 +1,23 @@
+# Auto-generated by the Koji build system
+
+config_opts['chroothome'] = '/builddir'
+config_opts['use_host_resolv'] = False
+config_opts['basedir'] = '/var/lib/mock'
+config_opts['rpmbuild_timeout'] = 86400
+config_opts['yum.conf'] = u'[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'
+config_opts['chroot_setup_cmd'] = 'groupinstall build'
+config_opts['target_arch'] = u'x86_64'
+config_opts['root'] = u'ROOTNAME'
+
+config_opts['plugin_conf']['root_cache_enable'] = False
+config_opts['plugin_conf']['yum_cache_enable'] = False
+config_opts['plugin_conf']['ccache_enable'] = False
+
+config_opts['macros']['%_host'] = u'x86_64-koji-linux-gnu'
+config_opts['macros']['%_host_cpu'] = u'x86_64'
+config_opts['macros']['%vendor'] = 'Koji'
+config_opts['macros']['%distribution'] = 'Unknown'
+config_opts['macros']['%_topdir'] = '/builddir/build'
+config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
+config_opts['macros']['%packager'] = 'Koji'
+
diff --git a/tests/test_lib/test_gen_mock_config.py b/tests/test_lib/test_gen_mock_config.py
new file mode 100644
index 0000000..274860f
--- /dev/null
+++ b/tests/test_lib/test_gen_mock_config.py
@@ -0,0 +1,27 @@
+import json
+import os
+import os.path
+import unittest
+
+import koji
+
+
+class TestGenMockConfig(unittest.TestCase):
+
+    def test_gen_mock_config(self):
+        datadir = os.path.join(os.path.dirname(__file__), 'data/mock')
+        count = 0
+        for fn in os.listdir(datadir):
+            if not fn.endswith('.json'):
+                continue
+            path = os.path.join(datadir, fn)
+            with open(path) as fo:
+                params = json.load(fo)
+            with open(path[:-5] + '.out') as fo:
+                expected = fo.read()
+            output = koji.genMockConfig(**params)
+            self.assertMultiLineEqual(output, expected)
+            count += 1
+        if not count:
+            raise Exception('no test data found')
+

From 90f95da3165e39da1466d5f3549deb697c40c97e Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Feb 28 2018 17:22:05 +0000
Subject: [PATCH 6/9] test internal_dev_setup option for getMockConfig


---

diff --git a/tests/test_lib/data/mock/internaldev.json b/tests/test_lib/data/mock/internaldev.json
new file mode 100644
index 0000000..36ab93f
--- /dev/null
+++ b/tests/test_lib/data/mock/internaldev.json
@@ -0,0 +1,8 @@
+{
+    "name": "ROOTNAME",
+    "arch": "x86_64",
+    "managed": false,
+    "repoid": 99,
+    "tag_name": "TAG",
+    "internal_dev_setup": false
+}
diff --git a/tests/test_lib/data/mock/internaldev.out b/tests/test_lib/data/mock/internaldev.out
new file mode 100644
index 0000000..609de88
--- /dev/null
+++ b/tests/test_lib/data/mock/internaldev.out
@@ -0,0 +1,24 @@
+# Auto-generated by the Koji build system
+
+config_opts['chroothome'] = '/builddir'
+config_opts['use_host_resolv'] = False
+config_opts['basedir'] = '/var/lib/mock'
+config_opts['rpmbuild_timeout'] = 86400
+config_opts['yum.conf'] = u'[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'
+config_opts['chroot_setup_cmd'] = 'groupinstall build'
+config_opts['target_arch'] = u'x86_64'
+config_opts['root'] = u'ROOTNAME'
+
+config_opts['plugin_conf']['root_cache_enable'] = False
+config_opts['plugin_conf']['yum_cache_enable'] = False
+config_opts['plugin_conf']['ccache_enable'] = False
+
+config_opts['internal_dev_setup'] = False
+config_opts['macros']['%_host'] = u'x86_64-koji-linux-gnu'
+config_opts['macros']['%_host_cpu'] = u'x86_64'
+config_opts['macros']['%vendor'] = 'Koji'
+config_opts['macros']['%distribution'] = 'Unknown'
+config_opts['macros']['%_topdir'] = '/builddir/build'
+config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
+config_opts['macros']['%packager'] = 'Koji'
+
diff --git a/tests/test_lib/data/mock/internaldev2.json b/tests/test_lib/data/mock/internaldev2.json
new file mode 100644
index 0000000..2c9a5c6
--- /dev/null
+++ b/tests/test_lib/data/mock/internaldev2.json
@@ -0,0 +1,8 @@
+{
+    "name": "ROOTNAME",
+    "arch": "x86_64",
+    "managed": false,
+    "repoid": 99,
+    "tag_name": "TAG",
+    "internal_dev_setup": true
+}
diff --git a/tests/test_lib/data/mock/internaldev2.out b/tests/test_lib/data/mock/internaldev2.out
new file mode 100644
index 0000000..f5d7d69
--- /dev/null
+++ b/tests/test_lib/data/mock/internaldev2.out
@@ -0,0 +1,24 @@
+# Auto-generated by the Koji build system
+
+config_opts['chroothome'] = '/builddir'
+config_opts['use_host_resolv'] = False
+config_opts['basedir'] = '/var/lib/mock'
+config_opts['rpmbuild_timeout'] = 86400
+config_opts['yum.conf'] = u'[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'
+config_opts['chroot_setup_cmd'] = 'groupinstall build'
+config_opts['target_arch'] = u'x86_64'
+config_opts['root'] = u'ROOTNAME'
+
+config_opts['plugin_conf']['root_cache_enable'] = False
+config_opts['plugin_conf']['yum_cache_enable'] = False
+config_opts['plugin_conf']['ccache_enable'] = False
+
+config_opts['internal_dev_setup'] = True
+config_opts['macros']['%_host'] = u'x86_64-koji-linux-gnu'
+config_opts['macros']['%_host_cpu'] = u'x86_64'
+config_opts['macros']['%vendor'] = 'Koji'
+config_opts['macros']['%distribution'] = 'Unknown'
+config_opts['macros']['%_topdir'] = '/builddir/build'
+config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
+config_opts['macros']['%packager'] = 'Koji'
+
diff --git a/tests/test_lib/data/mock/simple.json b/tests/test_lib/data/mock/simple.json
index 10ab345..d0e1ce5 100644
--- a/tests/test_lib/data/mock/simple.json
+++ b/tests/test_lib/data/mock/simple.json
@@ -3,6 +3,5 @@
     "arch": "x86_64",
     "managed": false,
     "repoid": 99,
-    "tag_name": "TAG",
-    "opts": {}
+    "tag_name": "TAG"
 }
diff --git a/tests/test_lib/test_gen_mock_config.py b/tests/test_lib/test_gen_mock_config.py
index 274860f..2d0bc37 100644
--- a/tests/test_lib/test_gen_mock_config.py
+++ b/tests/test_lib/test_gen_mock_config.py
@@ -8,6 +8,8 @@ import koji
 
 class TestGenMockConfig(unittest.TestCase):
 
+    maxDiff = None
+
     def test_gen_mock_config(self):
         datadir = os.path.join(os.path.dirname(__file__), 'data/mock')
         count = 0

From c3e8a2ecc73cb84b67c690687f4225252fde71e9 Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Feb 28 2018 17:22:05 +0000
Subject: [PATCH 7/9] stabilize mock config ordering


---

diff --git a/koji/__init__.py b/koji/__init__.py
index 1c593c8..328f60a 100644
--- a/koji/__init__.py
+++ b/koji/__init__.py
@@ -1530,10 +1530,12 @@ name=build
 """ % locals())
 
     parts.append("\n")
-    for key, value in six.iteritems(config_opts):
+    for key in sorted(config_opts):
+        value = config_opts[key]
         parts.append("config_opts[%r] = %r\n" % (key, value))
     parts.append("\n")
-    for key, value in six.iteritems(plugin_conf):
+    for key in sorted(plugin_conf):
+        value = plugin_conf[key]
         parts.append("config_opts['plugin_conf'][%r] = %r\n" % (key, value))
     parts.append("\n")
 
@@ -1549,10 +1551,12 @@ name=build
         parts.append("config_opts['internal_dev_setup'] = %r\n"
                 % bool(opts['internal_dev_setup']))
 
-    for key, value in six.iteritems(macros):
+    for key in sorted(macros):
+        value = macros[key]
         parts.append("config_opts['macros'][%r] = %r\n" % (key, value))
     parts.append("\n")
-    for key, value in six.iteritems(files):
+    for key in sorted(files):
+        value = files[key]
         parts.append("config_opts['files'][%r] = %r\n" % (key, value))
 
     return ''.join(parts)

From 3dda2f5dbf8e6402063fe16f4228b9044d7ef16d Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Feb 28 2018 17:22:05 +0000
Subject: [PATCH 8/9] handle internal_dev_setup opt earlier


---

diff --git a/koji/__init__.py b/koji/__init__.py
index 328f60a..8e40e30 100644
--- a/koji/__init__.py
+++ b/koji/__init__.py
@@ -1529,6 +1529,13 @@ name=build
 # Koji tag: %(tag_name)s
 """ % locals())
 
+    if bind_opts:
+        # disable internal_dev_setup unless opts explicitly say otherwise
+        opts.setdefault('internal_dev_setup', False)
+
+    if 'internal_dev_setup' in opts:
+        config_opts['internal_dev_setup'] = opts['internal_dev_setup']
+
     parts.append("\n")
     for key in sorted(config_opts):
         value = config_opts[key]
@@ -1540,17 +1547,11 @@ name=build
     parts.append("\n")
 
     if bind_opts:
-        # disable internal_dev_setup unless opts explicitly say otherwise
-        opts.setdefault('internal_dev_setup', False)
         for key in bind_opts.keys():
             for mnt_src, mnt_dest in six.iteritems(bind_opts.get(key)):
                 parts.append("config_opts['plugin_conf']['bind_mount_opts'][%r].append((%r, %r))\n" % (key, mnt_src, mnt_dest))
         parts.append("\n")
 
-    if 'internal_dev_setup' in opts:
-        parts.append("config_opts['internal_dev_setup'] = %r\n"
-                % bool(opts['internal_dev_setup']))
-
     for key in sorted(macros):
         value = macros[key]
         parts.append("config_opts['macros'][%r] = %r\n" % (key, value))

From 082f43ba3a5e51879f66ac7ac5c1bf4e35e10630 Mon Sep 17 00:00:00 2001
From: Mike McLean <mikem@redhat.com>
Date: Feb 28 2018 17:22:05 +0000
Subject: [PATCH 9/9] update unit tests


---

diff --git a/tests/test_lib/data/mock/internaldev.data b/tests/test_lib/data/mock/internaldev.data
new file mode 100644
index 0000000..7feae56
--- /dev/null
+++ b/tests/test_lib/data/mock/internaldev.data
@@ -0,0 +1,8 @@
+{
+    "name": "ROOTNAME",
+    "arch": "x86_64",
+    "managed": False,
+    "repoid": 99,
+    "tag_name": "TAG",
+    "internal_dev_setup": False
+}
diff --git a/tests/test_lib/data/mock/internaldev.json b/tests/test_lib/data/mock/internaldev.json
deleted file mode 100644
index 36ab93f..0000000
--- a/tests/test_lib/data/mock/internaldev.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "name": "ROOTNAME",
-    "arch": "x86_64",
-    "managed": false,
-    "repoid": 99,
-    "tag_name": "TAG",
-    "internal_dev_setup": false
-}
diff --git a/tests/test_lib/data/mock/internaldev.out b/tests/test_lib/data/mock/internaldev.out
index 609de88..a9bd710 100644
--- a/tests/test_lib/data/mock/internaldev.out
+++ b/tests/test_lib/data/mock/internaldev.out
@@ -1,24 +1,24 @@
 # Auto-generated by the Koji build system
 
-config_opts['chroothome'] = '/builddir'
-config_opts['use_host_resolv'] = False
 config_opts['basedir'] = '/var/lib/mock'
-config_opts['rpmbuild_timeout'] = 86400
-config_opts['yum.conf'] = u'[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'
 config_opts['chroot_setup_cmd'] = 'groupinstall build'
-config_opts['target_arch'] = u'x86_64'
-config_opts['root'] = u'ROOTNAME'
+config_opts['chroothome'] = '/builddir'
+config_opts['internal_dev_setup'] = False
+config_opts['root'] = 'ROOTNAME'
+config_opts['rpmbuild_timeout'] = 86400
+config_opts['target_arch'] = 'x86_64'
+config_opts['use_host_resolv'] = False
+config_opts['yum.conf'] = '[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'
 
+config_opts['plugin_conf']['ccache_enable'] = False
 config_opts['plugin_conf']['root_cache_enable'] = False
 config_opts['plugin_conf']['yum_cache_enable'] = False
-config_opts['plugin_conf']['ccache_enable'] = False
 
-config_opts['internal_dev_setup'] = False
-config_opts['macros']['%_host'] = u'x86_64-koji-linux-gnu'
-config_opts['macros']['%_host_cpu'] = u'x86_64'
-config_opts['macros']['%vendor'] = 'Koji'
-config_opts['macros']['%distribution'] = 'Unknown'
-config_opts['macros']['%_topdir'] = '/builddir/build'
+config_opts['macros']['%_host'] = 'x86_64-koji-linux-gnu'
+config_opts['macros']['%_host_cpu'] = 'x86_64'
 config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
+config_opts['macros']['%_topdir'] = '/builddir/build'
+config_opts['macros']['%distribution'] = 'Unknown'
 config_opts['macros']['%packager'] = 'Koji'
+config_opts['macros']['%vendor'] = 'Koji'
 
diff --git a/tests/test_lib/data/mock/internaldev2.data b/tests/test_lib/data/mock/internaldev2.data
new file mode 100644
index 0000000..e1b3f08
--- /dev/null
+++ b/tests/test_lib/data/mock/internaldev2.data
@@ -0,0 +1,8 @@
+{
+    "name": "ROOTNAME",
+    "arch": "x86_64",
+    "managed": False,
+    "repoid": 99,
+    "tag_name": "TAG",
+    "internal_dev_setup": True
+}
diff --git a/tests/test_lib/data/mock/internaldev2.json b/tests/test_lib/data/mock/internaldev2.json
deleted file mode 100644
index 2c9a5c6..0000000
--- a/tests/test_lib/data/mock/internaldev2.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "name": "ROOTNAME",
-    "arch": "x86_64",
-    "managed": false,
-    "repoid": 99,
-    "tag_name": "TAG",
-    "internal_dev_setup": true
-}
diff --git a/tests/test_lib/data/mock/internaldev2.out b/tests/test_lib/data/mock/internaldev2.out
index f5d7d69..034dc79 100644
--- a/tests/test_lib/data/mock/internaldev2.out
+++ b/tests/test_lib/data/mock/internaldev2.out
@@ -1,24 +1,24 @@
 # Auto-generated by the Koji build system
 
-config_opts['chroothome'] = '/builddir'
-config_opts['use_host_resolv'] = False
 config_opts['basedir'] = '/var/lib/mock'
-config_opts['rpmbuild_timeout'] = 86400
-config_opts['yum.conf'] = u'[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'
 config_opts['chroot_setup_cmd'] = 'groupinstall build'
-config_opts['target_arch'] = u'x86_64'
-config_opts['root'] = u'ROOTNAME'
+config_opts['chroothome'] = '/builddir'
+config_opts['internal_dev_setup'] = True
+config_opts['root'] = 'ROOTNAME'
+config_opts['rpmbuild_timeout'] = 86400
+config_opts['target_arch'] = 'x86_64'
+config_opts['use_host_resolv'] = False
+config_opts['yum.conf'] = '[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'
 
+config_opts['plugin_conf']['ccache_enable'] = False
 config_opts['plugin_conf']['root_cache_enable'] = False
 config_opts['plugin_conf']['yum_cache_enable'] = False
-config_opts['plugin_conf']['ccache_enable'] = False
 
-config_opts['internal_dev_setup'] = True
-config_opts['macros']['%_host'] = u'x86_64-koji-linux-gnu'
-config_opts['macros']['%_host_cpu'] = u'x86_64'
-config_opts['macros']['%vendor'] = 'Koji'
-config_opts['macros']['%distribution'] = 'Unknown'
-config_opts['macros']['%_topdir'] = '/builddir/build'
+config_opts['macros']['%_host'] = 'x86_64-koji-linux-gnu'
+config_opts['macros']['%_host_cpu'] = 'x86_64'
 config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
+config_opts['macros']['%_topdir'] = '/builddir/build'
+config_opts['macros']['%distribution'] = 'Unknown'
 config_opts['macros']['%packager'] = 'Koji'
+config_opts['macros']['%vendor'] = 'Koji'
 
diff --git a/tests/test_lib/data/mock/simple.data b/tests/test_lib/data/mock/simple.data
new file mode 100644
index 0000000..0fdf03d
--- /dev/null
+++ b/tests/test_lib/data/mock/simple.data
@@ -0,0 +1,7 @@
+{
+    "name": "ROOTNAME",
+    "arch": "x86_64",
+    "managed": False,
+    "repoid": 99,
+    "tag_name": "TAG"
+}
diff --git a/tests/test_lib/data/mock/simple.json b/tests/test_lib/data/mock/simple.json
deleted file mode 100644
index d0e1ce5..0000000
--- a/tests/test_lib/data/mock/simple.json
+++ /dev/null
@@ -1,7 +0,0 @@
-{
-    "name": "ROOTNAME",
-    "arch": "x86_64",
-    "managed": false,
-    "repoid": 99,
-    "tag_name": "TAG"
-}
diff --git a/tests/test_lib/data/mock/simple.out b/tests/test_lib/data/mock/simple.out
index 9759669..71d5dae 100644
--- a/tests/test_lib/data/mock/simple.out
+++ b/tests/test_lib/data/mock/simple.out
@@ -1,23 +1,23 @@
 # Auto-generated by the Koji build system
 
-config_opts['chroothome'] = '/builddir'
-config_opts['use_host_resolv'] = False
 config_opts['basedir'] = '/var/lib/mock'
-config_opts['rpmbuild_timeout'] = 86400
-config_opts['yum.conf'] = u'[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'
 config_opts['chroot_setup_cmd'] = 'groupinstall build'
-config_opts['target_arch'] = u'x86_64'
-config_opts['root'] = u'ROOTNAME'
+config_opts['chroothome'] = '/builddir'
+config_opts['root'] = 'ROOTNAME'
+config_opts['rpmbuild_timeout'] = 86400
+config_opts['target_arch'] = 'x86_64'
+config_opts['use_host_resolv'] = False
+config_opts['yum.conf'] = '[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\nkeepcache=1\ninstall_weak_deps=0\nstrict=1\n\n# repos\n\n[build]\nname=build\nbaseurl=file:///mnt/koji/repos/TAG/99/x86_64\n'
 
+config_opts['plugin_conf']['ccache_enable'] = False
 config_opts['plugin_conf']['root_cache_enable'] = False
 config_opts['plugin_conf']['yum_cache_enable'] = False
-config_opts['plugin_conf']['ccache_enable'] = False
 
-config_opts['macros']['%_host'] = u'x86_64-koji-linux-gnu'
-config_opts['macros']['%_host_cpu'] = u'x86_64'
-config_opts['macros']['%vendor'] = 'Koji'
-config_opts['macros']['%distribution'] = 'Unknown'
-config_opts['macros']['%_topdir'] = '/builddir/build'
+config_opts['macros']['%_host'] = 'x86_64-koji-linux-gnu'
+config_opts['macros']['%_host_cpu'] = 'x86_64'
 config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
+config_opts['macros']['%_topdir'] = '/builddir/build'
+config_opts['macros']['%distribution'] = 'Unknown'
 config_opts['macros']['%packager'] = 'Koji'
+config_opts['macros']['%vendor'] = 'Koji'
 
diff --git a/tests/test_lib/test_gen_mock_config.py b/tests/test_lib/test_gen_mock_config.py
index 2d0bc37..9afe1a0 100644
--- a/tests/test_lib/test_gen_mock_config.py
+++ b/tests/test_lib/test_gen_mock_config.py
@@ -1,4 +1,4 @@
-import json
+import ast
 import os
 import os.path
 import unittest
@@ -14,11 +14,12 @@ class TestGenMockConfig(unittest.TestCase):
         datadir = os.path.join(os.path.dirname(__file__), 'data/mock')
         count = 0
         for fn in os.listdir(datadir):
-            if not fn.endswith('.json'):
+            if not fn.endswith('.data'):
                 continue
             path = os.path.join(datadir, fn)
             with open(path) as fo:
-                params = json.load(fo)
+                s = fo.read()
+                params = ast.literal_eval(s)
             with open(path[:-5] + '.out') as fo:
                 expected = fo.read()
             output = koji.genMockConfig(**params)

