Skip to content

Commit

Permalink
Merge pull request Yelp#523 from irskep/no_mrjob_confs
Browse files Browse the repository at this point in the history
Test case for something I broke today, and corresponding fix
  • Loading branch information
David Marin committed Aug 1, 2012
2 parents c7f650d + 6294cee commit 61f662c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mrjob/runner.py
Expand Up @@ -153,7 +153,7 @@ def __init__(self, alias, opts, conf_paths):

if (len(self.cascading_dicts) > 2 and
all(len(d) == 0 for d in self.cascading_dicts[2:-1]) and
(len(conf_paths) > 0 or len(opts) == 0)):
(len(conf_paths or []) > 0 or len(opts) == 0)):
log.warning('No configs specified for %s runner' % alias)

self.populate_values_from_cascading_dicts()
Expand Down
24 changes: 24 additions & 0 deletions tests/test_inline.py
Expand Up @@ -16,9 +16,19 @@
from __future__ import with_statement

from StringIO import StringIO

import gzip
import os

try:
from unittest2 import TestCase
TestCase # silence pyflakes warning
except ImportError:
from unittest import TestCase

from mock import patch

from mrjob import conf
from mrjob.inline import InlineMRJobRunner
from mrjob.protocol import JSONValueProtocol
from tests.mr_test_cmdenv import MRTestCmdenv
Expand Down Expand Up @@ -148,3 +158,17 @@ def test_adding_2(self):
for line in runner.stream_output())

self.assertEqual(output, [2, 3, 4])


class NoMRJobConfTestCase(TestCase):

def test_no_mrjob_confs(self):
with patch.object(conf, 'real_mrjob_conf_path', return_value=None):
mr_job = MRIncrementerJob(['-r', 'inline', '--times', '2'])
mr_job.sandbox(stdin=StringIO('0\n1\n2\n'))

with mr_job.make_runner() as runner:
runner.run()
output = sorted(mr_job.parse_output_line(line)[1]
for line in runner.stream_output())
self.assertEqual(output, [2, 3, 4])

0 comments on commit 61f662c

Please sign in to comment.