Python script to find employees who are in one PostgreSQL table but not in another
LEFT JOIN from test_test to test_table selecting only rows where test_table.test_emp_id is null.

select emp_id 
from test_test
left join test_table on (
    test_table.test_emp_id = test_test.emp_id and
    test_table.state = 'test_state'
)
where (
    test_test.flag = true and 
    test_test.emp_id is not null and
    test_test.ver_id in (
        select id
        from test_phases
        where state = 'test'
    ) and
    test_table.test_emp_id is null
)


You may also want to consider: 


Using an inner join instead of a subquery to select only rows with test_phases.state = 'test'. 
Selecting distinct emp_ids if test_test.emp_id does not have a unique constraint.




select distinct emp_id 
from test_test
inner join test_phases on test_phases.id = test_test.ver_id
left join test_table on (
    test_table.test_emp_id = test_test.emp_id and
    test_table.state = 'test_state'
)
where (
    test_test.flag = true and 
    test_test.emp_id is not null and
    test_phases.state = 'test' and
    test_table.test_emp_id is null
)