Skip to content

RuntimeError: command not found: initdb #38

Description

@Priyadhana

Hi , I wanted to write test-cases involving postgres for flask applicattion. When I was trying the testing.postgresql package, it's throwing this command not found: initdb error.
This is the code I'm trying,

import unittest
import testing.postgresql

Generate Postgresql class which shares the generated database

Postgresql = testing.postgresql.PostgresqlFactory(cache_initialized_db=True)

def tearDownModule(self):
# clear cached database at end of tests
Postgresql.clear_cache()

class MyTestCase(unittest.TestCase):
def setUp(self):
# Use the generated Postgresql class instead of testing.postgresql.Postgresql
self.postgresql = Postgresql()

def tearDown(self):
    self.postgresql.stop()

When I ran pytest, I'm getting this error,

src\tests\app\test_db.py:25: in
Postgresql = testing.postgresql.PostgresqlFactory(cache_initialized_db=True)
..\user\appdata\local\programs\python\python39\lib\site-packages\testing\common\database.py:52: in init
self.cache = self.target_class(**settings_noautostart)
..\user\appdata\local\programs\python\python39\lib\site-packages\testing\common\database.py:92: in init
self.initialize()
..\user\appdata\local\programs\python\python39\lib\site-packages\testing\postgresql.py:50: in initialize
self.initdb = find_program('initdb', ['bin'])
..\user\appdata\local\programs\python\python39\lib\site-packages\testing\postgresql.py:144: in find_program
raise RuntimeError("command not found: %s" % name)
E RuntimeError: command not found: initdb

I have set the path for "C:\Program Files\PostgreSQL\13\bin" in my environmental.

Am I missing something? Can someone help me out here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions