diff --git a/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/CMakeLists.txt
index 03a6d01115cce93170b3bea1bcaba06718243287..9cd1a70bd5a8821925ebe4df7d863e3d93bfd651 100644
--- a/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/CMakeLists.txt
+++ b/PhysicsAnalysis/ElectronPhotonID/PhotonVertexSelection/CMakeLists.txt
@@ -28,5 +28,7 @@ atlas_add_dictionary( PhotonVertexSelectionDict
    LINK_LIBRARIES PhotonVertexSelectionLib )
 
 # Test(s) in the package:
-atlas_add_test( PhotonVertexSelection_test
-   SCRIPT test/testPhotonVertexSelection.py )
+if( NOT XAOD_ANALYSIS )
+   atlas_add_test( PhotonVertexSelection_test
+      SCRIPT test/testPhotonVertexSelection.py )
+endif()
diff --git a/PhysicsAnalysis/ElectronPhotonID/egammaMVACalibAnalysis/CMakeLists.txt b/PhysicsAnalysis/ElectronPhotonID/egammaMVACalibAnalysis/CMakeLists.txt
index 035ff8a01ef37f1b38264961041da650d70e7f85..e613f35f296578d248c395d433028ba4c72dd015 100644
--- a/PhysicsAnalysis/ElectronPhotonID/egammaMVACalibAnalysis/CMakeLists.txt
+++ b/PhysicsAnalysis/ElectronPhotonID/egammaMVACalibAnalysis/CMakeLists.txt
@@ -47,7 +47,7 @@ endif()
 # Install files from the package:
 atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
 
-if (NOT XAOD_STANDALONE)
+if (NOT XAOD_STANDALONE AND NOT XAOD_ANALYSIS)
   atlas_add_test( flake8_test
                   SCRIPT ${ATLAS_FLAKE8} ${CMAKE_CURRENT_SOURCE_DIR}/test
                   POST_EXEC_SCRIPT nopost.sh )