
import unittest

import orchard


class AppUnitTest(unittest.TestCase):

    def setUp(self):
        app = orchard.create_app('Testing')
        self.app_context = app.app_context()
        self.app_context.push()
        self.client = app.test_client(use_cookies = True)

    def tearDown(self):
        self.app_context.pop()

    def test_index(self):
        response = self.client.get('/')
        data = response.get_data(as_text = True)
        self.assertEqual(response.status_code, 200)
        self.assertTrue('Welcome to the Orchard!' in data)

        response = self.client.get('/BMeu')
        data = response.get_data(as_text = True)
        self.assertEqual(response.status_code, 200)
        self.assertTrue('Welcome to the Orchard, BMeu!' in data)


import unittest

import orchard


class AppUnitTest(unittest.TestCase):

    def setUp(self):
        app = orchard.create_app('Testing')
        app.config['BABEL_DEFAULT_LOCALE'] = 'en'
        self.app_context = app.app_context()
        self.app_context.push()
        self.client = app.test_client(use_cookies = True)

    def tearDown(self):
        self.app_context.pop()

    def test_index(self):
        response = self.client.get('/')
        data = response.get_data(as_text = True)
        self.assertEqual(response.status_code, 200)
        self.assertTrue('Welcome to the Orchard!' in data)

        response = self.client.get('/BMeu')
        data = response.get_data(as_text = True)
        self.assertEqual(response.status_code, 200)
        self.assertTrue('Welcome to the Orchard, BMeu!' in data)

Set default locale in test to avoid test failures when different default is used than expected.
Set default locale in test to avoid test failures when different default is used than expected.

  
  import unittest
  
  import orchard
  
  
  class AppUnitTest(unittest.TestCase):
  
      def setUp(self):
          app = orchard.create_app('Testing')
+         app.config['BABEL_DEFAULT_LOCALE'] = 'en'
          self.app_context = app.app_context()
          self.app_context.push()
          self.client = app.test_client(use_cookies = True)
  
      def tearDown(self):
          self.app_context.pop()
  
      def test_index(self):
          response = self.client.get('/')
          data = response.get_data(as_text = True)
          self.assertEqual(response.status_code, 200)
          self.assertTrue('Welcome to the Orchard!' in data)
  
          response = self.client.get('/BMeu')
          data = response.get_data(as_text = True)
          self.assertEqual(response.status_code, 200)
          self.assertTrue('Welcome to the Orchard, BMeu!' in data)
  
Set default locale in test to avoid test failures when different default is used than expected.
## Code Before:

import unittest

import orchard


class AppUnitTest(unittest.TestCase):

    def setUp(self):
        app = orchard.create_app('Testing')
        self.app_context = app.app_context()
        self.app_context.push()
        self.client = app.test_client(use_cookies = True)

    def tearDown(self):
        self.app_context.pop()

    def test_index(self):
        response = self.client.get('/')
        data = response.get_data(as_text = True)
        self.assertEqual(response.status_code, 200)
        self.assertTrue('Welcome to the Orchard!' in data)

        response = self.client.get('/BMeu')
        data = response.get_data(as_text = True)
        self.assertEqual(response.status_code, 200)
        self.assertTrue('Welcome to the Orchard, BMeu!' in data)

## Instruction:
Set default locale in test to avoid test failures when different default is used than expected.
## Code After:

import unittest

import orchard


class AppUnitTest(unittest.TestCase):

    def setUp(self):
        app = orchard.create_app('Testing')
        app.config['BABEL_DEFAULT_LOCALE'] = 'en'
        self.app_context = app.app_context()
        self.app_context.push()
        self.client = app.test_client(use_cookies = True)

    def tearDown(self):
        self.app_context.pop()

    def test_index(self):
        response = self.client.get('/')
        data = response.get_data(as_text = True)
        self.assertEqual(response.status_code, 200)
        self.assertTrue('Welcome to the Orchard!' in data)

        response = self.client.get('/BMeu')
        data = response.get_data(as_text = True)
        self.assertEqual(response.status_code, 200)
        self.assertTrue('Welcome to the Orchard, BMeu!' in data)
